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?
C:\\Test\\Test1\\a.txt
How about:
Directory.CreateDirectory(Path.GetDirectoryName(filename));