I am having a problem in deleting Files,MainFolder And SubFolders in a Directory. I want to delete all the Files,MainFolders and Subfolders after the work is finish . I am using this following code.
private void bgAtoZ_DoWork(object sender, DoWorkEventArgs e)
{
string Path1 = (string)(Application.StartupPath + "\\TEMP\\a-z\\test" + "\\" +name);
StreamReader reader1 = File.OpenText(Path1);
string str = reader1.ReadToEnd();
reader1.Close();
reader1.Dispose();
File.Delete(Path1);
}
If anyone Would help me it would be nice for me. Thanks In Advance
Direcory.Delete(path, true);
See here
I'd go for a:
Directory.Delete(Path1, true)
that will delete folders and files contained.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With