If a folder does not exist, create it
If a folder does not exist, create it
If a folder does not exist, create it
Re: If a folder does not exist, create it
Use **`System.IO.Directory.CreateDirectory`**.
According to the official [".NET" docs](https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.createdirectory), you don't need to check if it exists first.
[System.io](https://learn.microsoft.com/en-us/dotnet/api/system.io) > [Directory](https://learn.microsoft.com/en-us/dotnet/api/system.io.directory) > [Directory.CreateDirectory](https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.createdirectory)
Any and all directories specified in `path` are created, unless they already exist or unless some part of `path` is invalid. If the directory already exists, this method does not create a new directory, but it returns a `DirectoryInfo` object for the existing directory.
***[— learn.microsoft.com/dotnet/api/](https://learn.microsoft.com/dotnet/api/)***
According to the official [".NET" docs](https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.createdirectory), you don't need to check if it exists first.
[System.io](https://learn.microsoft.com/en-us/dotnet/api/system.io) > [Directory](https://learn.microsoft.com/en-us/dotnet/api/system.io.directory) > [Directory.CreateDirectory](https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.createdirectory)
Any and all directories specified in `path` are created, unless they already exist or unless some part of `path` is invalid. If the directory already exists, this method does not create a new directory, but it returns a `DirectoryInfo` object for the existing directory.
***[— learn.microsoft.com/dotnet/api/](https://learn.microsoft.com/dotnet/api/)***