|
-
Apr 18th, 2010, 08:08 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Streamwriter file location
Hello all,
When there's no file path in the streamwriter constructor does anyone know the location the file gets output to?
ie
Code:
Dim sw as StreamWriter = new Streamwriter("test.txt")
sw.close
Thanks,
Strick
-
Apr 18th, 2010, 08:25 PM
#2
New Member
Re: Streamwriter file location
The file gets output to the working directory, which is usually the folder containing the executable. The user can change the working directory using a shortcut, though, and you can also change the working directory using ChDir and SetWorkingDirectory.
To always write to the application's folder, use:
Code:
Application.StartupPath & "\test.txt"
-
Apr 18th, 2010, 08:26 PM
#3
Re: Streamwriter file location
The "current" directory. Could be where the app is located. Could be the root.... could be anywhere. Generally speaking, it's a good idea to include the path where you want the file to be.
-tg
-
Apr 19th, 2010, 11:10 AM
#4
Thread Starter
Fanatic Member
Re: Streamwriter file location
 Originally Posted by techgnome
The "current" directory. Could be where the app is located. Could be the root.... could be anywhere. Generally speaking, it's a good idea to include the path where you want the file to be.
-tg
Hi, I totally agree with you, and I always do. But i'm studying towards the MCPD certification and all the samples in the book where a file is being created does not have the full path, only the file name.
Thanks,
Strick
-
Apr 19th, 2010, 11:11 AM
#5
Thread Starter
Fanatic Member
Re: Streamwriter file location
 Originally Posted by Arrival
The file gets output to the working directory, which is usually the folder containing the executable. The user can change the working directory using a shortcut, though, and you can also change the working directory using ChDir and SetWorkingDirectory.
To always write to the application's folder, use:
Code:
Application.StartupPath & "\test.txt"
Hi, Thanks
I'll check there for it.
Strick
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|