If I create a save a text file, how do I get my application to save it into the end users directory?

Ive current got this which saves into my user area.

file = My.Computer.FileSystem.OpenTextFileWriter("C:\Users\#####\Fruit\Fruit.txt", False)




So if you were to stick that into my code it would be...?

file = My.Computer.FileSystem.SpecialDirectories.MyDocuments("Fruit\Fruit.txt", False)

Both are strings of the path.

file = My.Computer.FileSystem.OpenTextFileWriter(My.Computer.FileSystem.SpecialDirectories.MyDocuments, False)

Edited 5 Years Ago by Unhnd_Exception: n/a

And how do i add the file name fruits.txt

file = My.Computer.FileSystem.OpenTextFileWriter(My.Computer.FileSystem.SpecialDirectories.MyDocuments("fruits.txt")


Edited 5 Years Ago by BleepyE: n/a

Dim SavePath as string = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\fruits.txt"

That will give you the path to a file in mydocuments named fuits.txt

If you want to save it in the app directory use the second option that was posted in the first reply. Attach fruits.txt to it the same way

This question has already been answered. Start a new discussion instead.