file.create folder c# code example

Example 1: c# making a folder

string path1 = @"C:\temp\";
string path2 = Path.Combine(path1, "temp1");

// Create directory temp1 if it doesn't exist
Directory.CreateDirectory(path2);

Example 2: file.create folder c#

Using System.IO; 

//gets the directory where the program is launched from and adds the foldername
string path = Path.Combine(Environment.CurrentDirectory, "foldername");

//Creates a directory(folder) if it doesen't exist
Directory.CreateDirectory(path);

Example 3: how to create a folder in c#

// Directory class is in the System.IO namespace
Directory.CreateDirectory(dir);