public void DeleteAllFilesAndFolders(string folderPath)
{
try
{
if (String.IsNullOrEmpty(folderPath))
{
return;
}
foreach (string subDirectory in Directory.GetDirectories(folderPath))
{
foreach (string fileName in Directory.GetFiles(subDirectory))
{
File.Delete(fileName);
}
DeleteAllFilesAndFolders(subDirectory);
}
if (Directory.Exists(folderPath))
{
Directory.Delete(folderPath, true);
}
}
catch
{
}
}
Search This Blog
February 10, 2010
Delete files and folders recurcively
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment