Saturday, January 5, 2013

How to Create a Folder in C#.NET


To create a directory in C#.NET use the below code.

string pathToCreate = "~/UserFolder";// "UserFolder" is the folder name to be created

if (!Directory.Exists(pathToCreate)) // Check whether a folder exists in the same name
{
  Directory.CreateDirectory(Server.MapPath(pathToCreate));// Create folder
}

Directory will be created in your application root.

No comments:
Write comments
Recommended Posts × +