This will create a file along with folders a and bb if they do not exist.
FileInfo fi = new FileInfo(@".\a\bb\file.txt");
DirectoryInfo di = new DirectoryInfo(@".\a\bb");
if(!di.Exists)
{
di.Create();
}
if (!fi.Exists)
{
fi.Create().Dispose();
}
source
share