How can I create a new folder in asp.net using c#?
ASP CreateFolder() Method The ASP CreateFolder Method is used to create a new directory or folder in the Server. It is a predefined method of the FileSystem Object. It accepts the name of the folder as a parameter.
var folder = Server.MapPath("~/App_Data/uploads/random");
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
path
is the variable holding the directory name
Directory.CreateDirectory(path);
You can read more about it here
Directory.CreateDirectory. However you will have to make sure the application pool user has rights to create the directory.
if (!Directory.Exists(Path))
{
Directory.CreateDirectory(Path);
}
try this, for a better one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With