How to create a folder in Asp.Net?

 Posted by Vishalneeraj-24503 on 2/4/2015 | Category: ASP.NET Interview questions | Views: 530 | Points: 40
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 

Comments or Responses

Login to post response