473,569 Members | 2,731 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("M yText"))
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 6544
Ben,

try

Environment.Get FolderPath(Envi ronment.Special Folder.Personal )

to get that path.

Klaus

"Ben" <be*******@hotm ail.com> schrieb im Newsbeitrag
news:ev******** ******@TK2MSFTN GP10.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("M yText"))
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*******@hotm ail.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("M yText"))
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.Get FolderPath( _
Environment.Spe cialFolder.Pers onal _
)

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.Get FolderPath(Envi ronment.Special Folder.Personal )

I hope this helps?

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

It's running...

"Armin Zingler" <az*******@free net.de> a écrit dans le message de news:
40************* **********@news .freenet.de...
"Ben" <be*******@hotm ail.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("M yText"))
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.Get FolderPath( _
Environment.Spe cialFolder.Pers onal _
)

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

33
9132
by: Jim Hill | last post by:
I've done some Googling around on this and it seems like creating a here document is a bit tricky with Python. Trivial via triple-quoted strings if there's no need for variable interpolation but requiring a long, long formatted arglist via (%s,%s,%s,ad infinitum) if there is. So my question is: Is there a way to produce a very long...
0
2454
by: Grant_S | last post by:
I need to identify the path to a users "My Document" folder where the user has a roaming profile and their "My Documents" folder is mapped to a network share as the H drive (specifically H:\\ - where the "My Received Files" folder path then is H:\\My Refeceived Files. The double \\ is not an escape character as subfolders only have sinvle "\"...
1
2945
by: jj | last post by:
How do I programatically default the encoding of my "Notepad" into ANSI. My application uses notepad to save some text. Some of the client computers have UTF as the default encoding in their notepad. This adds some characters in my text and creates problems later on managing it. So is there a way to create a text file in notepad with ANSI...
6
13260
by: JuLiE Dxer | last post by:
Is there a way via C# to programmatically retrieve the full path name to folders like "My Documents" ?? I'm seeing examples with the use of Shell32 stuff I believe, SHGetSpecialFolderLocation and I have no knowledge nor experience using such stuff. I've seen some examples pertaining to these special folders but it's all Greek to me and...
8
2260
by: Tony Nelson | last post by:
On *nix, ~/foo refers to a file in a user's home directory. On MSWindows, users normally look at "My Documents" in their home directory. ISTM that a file that my program would put in ~/. on Linux should be put in "~/My Documents/" (modulo os.path.normpath()) on MSWindows, where a user would expect it. How do you guys cope with this issue?...
1
1857
by: Jeremy | last post by:
I don't know if this is really a javascript question but thought I may as well start here... I know that a "document" is what is displayed in a browser window. However it is possible for the docuemnt that is displayed to be composed from a number of documents with perhaps a separator between each one. In our application, the user would at...
42
3107
by: Martin Jørgensen | last post by:
Hi, I'm trying to move a matlab program into c language. For those who knows matlab, this is the line I want to program in c: hx(1:nx,1:ny) = 0; % nx=10, ny=10 It works on a 2-dimensional array (size is 10*10), setting all the values inside the 10*10 matrix to zero. My C-function looks like this:
4
2097
by: Franky | last post by:
I know about GetModuleFileName but what I need is a similar call to get the folder "My Documents" Is there such a thing? Thanks
3
1361
by: Jack | last post by:
Hi there, In a submit button event, I need to open a (server-side) file relative to the folder containing the ".aspx" file. What's the correct way to locate the ".aspx" folder itself inside my handler? Thanks in advance.
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.