Hi I want to delete a folder in asp.net To create the folder Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Docs/"), idtxt.Text));
¿But how I can delete it?
thanks
This way
protected void Page_Load(object sender, EventArgs e) { string path = @"E:\NewFolder\"; DeleteDirectory(path); } private void DeleteDirectory(string path) { if (Directory.Exists(path)) { //Delete all files from the Directory foreach (string file in Directory.GetFiles(path)) { File.Delete(file); } //Delete all child Directories foreach (string directory in Directory.GetDirectories(path)) { DeleteDirectory(directory); } //Delete a Directory Directory.Delete(path); } }
© COPYRIGHT 2024 ASPSnippets.com ALL RIGHTS RESERVED.