Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

StreamWriter(string filename)

 

I wanna write to a file named "exceptions.log". This is how I create the instance of the StreamWriter:

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. I'm just curious. I could easily input the absolute path or use the Application.StartUpPath and the like.

 

Thx.

Amir Syafrudin
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...