Reputation: 1346
How to specify path for StreamWriter with up two level:
As an example project located at D:\Projects\ffp\bin\Debug> need to do cd ../../ and then save in LOG directory means like D:\Projects\ffp\LOG\test.txt
I try do describe - no matter what path is would be always need to save in two levels higher.
Upvotes: 0
Views: 113
Reputation: 173
CodeCaster's comment should be correct...
new StreamWriter(@"..\..\Log\filename.log")
Should go back/down two directories and then forward/up into the "Log" folder. I do not believe the folder will be created automatically.
Use the Exist and CreateDirectory methods off the Directory object if you need to create the folder first:
http://msdn.microsoft.com/en-us/library/system.io.directory.exists(v=vs.110).aspx http://msdn.microsoft.com/en-us/library/54a0at6s(v=vs.110).aspx
Upvotes: 1