Answered by:
Writing to CSV File

Question
-
Guys
Can anyone point me to any samples that will show me how to write to a CSV File.
There are some example here but all in C#
My App is in Visual Basic and Im using Windows 8.1 VS 2013
I have 6 textboxs on my page each with some text in. I need to save them when i click a button as one line in a CSV file appended to whatever is already in the file
The idea is I can then load the CSV into excel and use the data to poulate a form and send email
Any Ideas where I start
Mark
Sunday, November 3, 2013 7:41 AM
Answers
-
Ok Managed to sort the append
Await Windows.Storage.FileIO.AppendTextAsync(sampleFile, dave.ToString)
This does append to the file but on the same line
How do I send a LfCr so that the second text is on the next line of the file
Mark
- Marked as answer by wambaugh1 Monday, November 4, 2013 2:09 PM
Sunday, November 3, 2013 9:57 PM
All replies
-
guys
I have the following code to get the contents of the 6 text boxes into a variable
Dim dave
dave = tb1.Text & "," & tb2.Text & "," & tb3.Text & "," & tb4.Text & "," & tb5.Text & "," & tb6.Text
what i Need to do is append the variable "dave" to the CSV file "C:\data.csv"
Mark
Sunday, November 3, 2013 7:56 AM -
Guys
I have worked out the following
Private Async Sub savebutton_Click(sender As Object, e As RoutedEventArgs) Handles savebutton.Click
Dim dave
dave = pageTitle.Text & "," & comboBox1.SelectedItem.ToString & "," & comboBox2.SelectedItem.ToString & "," & room.Text & "," & fault.Text & "," & comboBox3.SelectedItem.ToString & "," & phototextbox.Text
Dim storageFolder As StorageFolder = KnownFolders.DocumentsLibrary
Dim sampleFile As StorageFile = Await storageFolder.CreateFileAsync("sample.csv")
Await Windows.Storage.FileIO.AppendTextAsync(sampleFile, dave.ToString)
End SubThis works perfectly as long as there is no file called "sample.csv"
I need to sort 3 things
1. Check if the file exists
2. Change the storage folder as the defaultDocuments folder is on my sky drive and not in Users folder
3. Instead of creating a new file I need to append to an existing file
I think I can appending using
FileIO.AppendTextAsync(storageFolder , String)
But I can't workout how to specify the storageFolder element
Any Ideas
Mark
Sunday, November 3, 2013 9:40 PM -
Ok Managed to sort the append
Await Windows.Storage.FileIO.AppendTextAsync(sampleFile, dave.ToString)
This does append to the file but on the same line
How do I send a LfCr so that the second text is on the next line of the file
Mark
- Marked as answer by wambaugh1 Monday, November 4, 2013 2:09 PM
Sunday, November 3, 2013 9:57 PM