Save Text file to "My Documents"

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
 
C

Cor Ligthert

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
 
K

Klaus Löffelmann

Ben,

try

Environment.GetFolderPath(Environment.SpecialFolder.Personal)

to get that path.

Klaus
 
A

Armin Zingler

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
 
B

Ben

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top