DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Delete All The Files In Specified Directory In Asp.net
// Delete all the files in specified directory in asp.net
private void DeleteAllFilesInMyDirectory(string MyDirectoryPath)
{
if (Directory.Exists(HttpContext.Current.Server.MapPath(MyDirectoryPath)))
{
string[] filenames = System.IO.Directory.GetFiles(HttpContext.Current.Server.MapPath(MyDirectoryPath));
foreach (string filename in currntDirectoryFilenames)
{
File.Delete(filename);
}
}
}





