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)

Thanks

Member Avatar for Unhnd_Exception
My.Computer.FileSystem.SpecialDirectories.MyDocuments

 My.Computer.FileSystem.CurrentDirectory

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

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

Both are strings of the path.

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

And how do i add the file name fruits.txt

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

This?

Member Avatar for Unhnd_Exception
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

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.