By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,359 Members | 1,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,359 IT Pros & Developers. It's quick & easy.

Save Text file to "My Documents"

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
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.