Default file path ...

amir100

Well-known member
Joined
Mar 14, 2004
Messages
190
Location
Indonesia
Hi all,

I am currently working with the StreamWriter class. I am using the constructor which has a string filepath for its parameter. The constructor should look like:
Code:
StreamWriter(string filename)

I wanna write to a file named "exceptions.log". This is how I create the instance of the StreamWriter:
Code:
StreamWriter sw = New StreamWriter("exceptions.log")

Now, my question is, why is .net tried to create a "C:\WINDOWS\system32\exceptions.log"? Is "C:\WINDOWS\system32" a default file path? If so, how do I change it?

This is not that big of a problem though. Im just curious. I could easily input the absolute path or use the Application.StartUpPath and the like.

Thx.
 
I would assume that the file is being created in the Current Working Directory

If you use a shortcut to a program, for example, there is the option to set the working directory there.

Because you are most likely running this from within the IDE, I would guess that your project "inherits" its CWD from the IDE, which is most likely c:\windows\system32

Under the Properties of your particular project, within the Configuration Properties tree item, you will see Debugging. Within there is the option to set your Working Directory, I believe that is what you will need!

B.
 
Back
Top