Quote:System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.IO.IOException: Access to the path 'E:\ws4test\foldertodelete\New Folder' is denied. at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive) at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive)
[WebMethod(Description = "automatically delete the folder mentioned in the path")] public string deletefoldermethod(string folderpath) { DirectoryInfo targetfolder = new DirectoryInfo(folderpath); string[] files = Directory.GetFiles(folderpath); string[] dirs = Directory.GetDirectories(folderpath); foreach (string file in files) { File.SetAttributes(file, FileAttributes.Normal); File.Delete(file); } foreach (string dir in dirs) { Directory.Delete(dir,true); } string msg = "Folder is successfully deleted"; return msg; }
localhost.deletefolder obj = new localhost.deletefolder(); string path = @"E:\ws4test\foldertodelete\"; string msg = obj.deletefoldermethod(path); lblmsg.Text = msg;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)