1

So I have this code in which I create a file:

string FilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "JMange") + @"\" + Project_Name + ".bin";

try
{
    using (var SerializeStream = new FileStream(FilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
        Formatter.Serialize(SerializeStream, NewEmployeeTree);

//(...)

but the thing is, that some of the folders in this path already exist, some not. so instead of checking if evry single folder exists, and creating it if it doesn't, and otherwise keep it the same, I thought that maybe I can create all the missing folders "In one go".

Is this possible?

dymanoid
  • 13,597
  • 3
  • 34
  • 59

1 Answers1

0

Yes.

Directory.CreateDirectory(directoryPath);

will create any missing folders in the path.

Robin Bennett
  • 2,982
  • 6
  • 16