Reputation: 5236
If I have a path C:\Test\Test1\a.txt
and Test1 doesn't exist, how can I ensure it is created before appending to a.txt?
Upvotes: 15
Views: 5778
Reputation: 1500805
How about:
Directory.CreateDirectory(Path.GetDirectoryName(filename));
Upvotes: 21