AleksP
AleksP

Reputation: 1346

StreamWriter path specify with up one or more levels

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

Answers (1)

SidF
SidF

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

Related Questions