469,903 Members | 1,520 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

Save Text file to "My Documents"

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
Nov 20 '05 #1
4 6399
Ben,

try

Environment.GetFolderPath(Environment.SpecialFolde r.Personal)

to get that path.

Klaus

"Ben" <be*******@hotmail.com> schrieb im Newsbeitrag
news:ev**************@TK2MSFTNGP10.phx.gbl...
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

Nov 20 '05 #2
"Ben" <be*******@hotmail.com> schrieb
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
Nov 20 '05 #3
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.SpecialFolde r.Personal)

I hope this helps?

Cor
Nov 20 '05 #4
Ben
THANKS !!!

It's running...

"Armin Zingler" <az*******@freenet.de> a écrit dans le message de news:
40***********************@news.freenet.de...
"Ben" <be*******@hotmail.com> schrieb
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

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

33 posts views Thread by Jim Hill | last post: by
1 post views Thread by Jeremy | last post: by
42 posts views Thread by Martin Jørgensen | last post: by
3 posts views Thread by Jack | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.