amir100 Posted August 31, 2005 Posted August 31, 2005 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. Quote Amir Syafrudin
penfold69 Posted August 31, 2005 Posted August 31, 2005 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.