Save Text file to "My Documents"

  • Thread starter Thread starter Ben
  • Start date Start date
B

Ben

Hello,

I need to save some information into a text file.
For this, I use :

FileOpen(1, "c:\MyFile.txt", OpenMode.Output)
For I = 0 To iCpt - 1
WriteLine(1, myDs.Tables(0).Rows(I).Item("MyText"))
Next
FileClose(1)

This is running...

BUT I would like to save the text file into "My Documents" of user whos run
application.
--> In place of : FileOpen(1, "c:\MyFile.txt", OpenMode.Output)
--> I would like : FileOpen(1,"c:\Documents and settings\[USER]\My
Documents", OpenMode.Output)

How know ?

Thanks

Ben
 
Hi Ben
BUT I would like to save the text file into "My Documents" of user whos run
application.

dim Myfolder as string =
Environment.GetFolderPath(Environment.SpecialFolder.Personal)

I hope this helps?

Cor
 
Ben,

try

Environment.GetFolderPath(Environment.SpecialFolder.Personal)

to get that path.

Klaus
 
Ben said:
Hello,

I need to save some information into a text file.
For this, I use :

FileOpen(1, "c:\MyFile.txt", OpenMode.Output)
For I = 0 To iCpt - 1
WriteLine(1, myDs.Tables(0).Rows(I).Item("MyText"))
Next
FileClose(1)

This is running...

BUT I would like to save the text file into "My Documents" of user
whos run application.
--> In place of : FileOpen(1, "c:\MyFile.txt", OpenMode.Output)
--> I would like : FileOpen(1,"c:\Documents and settings\[USER]\My
Documents", OpenMode.Output)

How know ?

dim Dirname, fullname as string

Dirname = Environment.GetFolderPath( _
Environment.SpecialFolder.Personal _
)

fullname = io.path.combine(dirname, "myfile.txt")


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
THANKS !!!

It's running...



Armin Zingler said:
Ben said:
Hello,

I need to save some information into a text file.
For this, I use :

FileOpen(1, "c:\MyFile.txt", OpenMode.Output)
For I = 0 To iCpt - 1
WriteLine(1, myDs.Tables(0).Rows(I).Item("MyText"))
Next
FileClose(1)

This is running...

BUT I would like to save the text file into "My Documents" of user
whos run application.
--> In place of : FileOpen(1, "c:\MyFile.txt", OpenMode.Output)
--> I would like : FileOpen(1,"c:\Documents and settings\[USER]\My
Documents", OpenMode.Output)

How know ?

dim Dirname, fullname as string

Dirname = Environment.GetFolderPath( _
Environment.SpecialFolder.Personal _
)

fullname = io.path.combine(dirname, "myfile.txt")


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Back
Top