ASP中的Directory.Delete问题 [英] Directory.Delete problem in asp

查看:119
本文介绍了ASP中的Directory.Delete问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我提供了一项删除路径中提到的任何文件夹的服务.我的Web服务发布在我的IIS服务器上.

我有另一个网页,该网页通过调用其中带有文件夹路径的方法来引用此Web服务.

我收到错误消息,因为

Hi All,

I made a service which deletes any folder mentioned in the path. my web service is published on my IIS server.

I have another web page which referring this web service by calling a method in it with the folder path.

I am getting an error as

报价:

System.Web.Services.Protocols.SoapException:服务器无法处理请求. ---> System.IO.IOException:拒绝访问路径"E:\ ws4test \ foldertodelete \ New文件夹".
在System.IO.Directory.DeleteHelper处(字符串fullPath,字符串userPath,布尔值递归)
在System.IO.Directory.Delete(字符串fullPath,字符串userPath,布尔值递归)

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)




我的网络方法如下:




my web method is as follows:

[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;
    }




和调用它的网页代码是..




and the web page code to call this is..

localhost.deletefolder obj = new localhost.deletefolder();
       string path = @"E:\ws4test\foldertodelete\";
       string msg = obj.deletefoldermethod(path);
       lblmsg.Text = msg;



我错过了什么吗?



Am I missing something???

推荐答案



请查看以下内容:

System.UnauthorizedAccessException:访问路径 [对路径的访问被拒绝 [
Hi,

Please have a look at the following:

System.UnauthorizedAccessException: Access to the path[^]
Access to the path is denied[^]

Kind regards,


检查这些博客
http://stackoverflow.com/questions/2235616/directory-deletepath-true-always-gives-error-asp-net-3-5-mvc [ http://stackoverflow.com/questions/6490305/system-ios-directory-delete-method-sometimes-work-but-sometimes-specially-in [
check these blogs
http://stackoverflow.com/questions/2235616/directory-deletepath-true-always-gives-error-asp-net-3-5-mvc[^]
http://stackoverflow.com/questions/6490305/system-ios-directory-delete-method-sometimes-work-but-sometimes-specially-in[^]
--NDK


这篇关于ASP中的Directory.Delete问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆