dimanche 10 mai 2015

Save textfile to appdata and then load from file vb.net

Ok what i am trying to do is this: I want to save data to a textfile that will be saved in appdata, i will be packaging up the application so the user will be installing it.

To write a text file here's my code:

 Dim file As System.IO.StreamWriter
        file = My.Computer.FileSystem.OpenTextFileWriter("test.txt", True)
        file.WriteLine(TextBox1.Text)
        file.Close()

This will save the file to the directory the app is run from, from what i see when i debug. But it to save to app data when the app is installed and ran, heres the code to save in app data:

Dim appDataPath As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

How do i make my textfile save to the string appdatapath? Im assuming i could only see the change if i try to package the app and install it myself? since it's debugging Visual studio wont actually make a folder in appdata for it right? But i want to be able to specify that location as the save location. Thanks. Using Visual Studio 2013

Aucun commentaire:

Enregistrer un commentaire