Create a Folder in C#
To create a folder in C# you can directly use method:Directory.CreateDirectory()
and pass the folder path as string parameter. It's recommended first to check whether the folder exist using method: Directory.Exists()
. Finally remember to include required namespaces using System.IO;
.Example
using System;
using System.IO;
public class Program
{
public static void Main()
{
string folderPath = @"D:\path_to_new_folder";
if (!Directory.Exists(folderPath)) {
Directory.CreateDirectory(folderPath);
}
}
}