Recursive delete files and folders using C#
This function will Recursively delete all files and folders.
private void DeleteAllFiles(string sPath) { foreach(string strFile in Directory.GetFiles(sPath)) { File.Delete(strFile); } foreach (string strDir in Directory.GetDirectories(sPath)) { DeleteAllFiles(strDir); } Directory.Delete(sPath); }