Answer: Using System.IO Namespace;
string path = @"c:\file1";
try
{
// check whether the directory exists.
if (Directory.Exists(path))
{
Response.Write("That path exists already.");
return;
}
// Try to create the directory.
DirectoryInfo di = Directory.CreateDirectory(path);
Response.Write("Directory create successfully at " + Directory.GetCreationTime(path));
}
catch(Exception ex)
{
Response.Write (ex.Message );
}
Asked In: Many Interviews |
Alert Moderator