How can I create a new folder in asp.net using c#?
54,425
Solution 1
path
is the variable holding the directory name
Directory.CreateDirectory(path);
You can read more about it here
Solution 2
var folder = Server.MapPath("~/App_Data/uploads/random");
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
Solution 3
Directory.CreateDirectory. However you will have to make sure the application pool user has rights to create the directory.
Solution 4
if (!Directory.Exists(Path))
{
Directory.CreateDirectory(Path);
}
try this, for a better one.
Solution 5
First, remember that the directory will appear on the server, not the client. You also have to have the rights to create the folder. Finally, in a load balanced environment the folder will appear only on the server that created it, it won't be replicated unless there is some background service that does that for you.
using System.IO;
Directory.CreateDirectory(folderPath);
Comments
-
jeevamuthu almost 2 years
How can I create a new folder in asp.net using c#?