如何使用directory.delete创建一个具有完整访问权限的目录 [英] How to create a directory with full acess which will be removed using directory.delete

查看:69
本文介绍了如何使用directory.delete创建一个具有完整访问权限的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii,



我正在尝试创建一个目录,后来我尝试刷新该目录..但在删除时它让我访问被拒绝该路径的错误..请建议..



 如果( Directory.Exists(deletePath))
{
Directory.Delete(ClearDirectory, true );
Directory.Delete(deletePath, true );
}

#endregion

if (!Directory.Exists(Server.MapPath(pdfExportPath)))
{
Directory.CreateDirectory(Server.MapPath(pdfExportPath));
}

解决方案

尝试以下代码,看看是否收到同样的错误。



  string  path = Server.MapPath(pdfExportPath); 
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}

使用(File.Create(Path.Combine(path, Test.txt)));

if (Directory.Exists(path))
{
Directory.Delete(path,);
}



您可以在该服务器上手动删除目录吗?

如果没有,请检查您所在帐户的访问权限使用。



由于您在不同的代码段中使用了不同的路径,这也有点令人困惑。

这是故意还是错误?


Hii ,

I am trying to create a directory and the later I try to flush that directory .. but at the time of deleteing it gives me access denied error for that path .. Please suggest ..

if (Directory.Exists(deletePath))
                        {
                            Directory.Delete(ClearDirectory, true);
                            Directory.Delete(deletePath, true);
                        }

                        #endregion

                        if (!Directory.Exists(Server.MapPath(pdfExportPath)))
                        {
                            Directory.CreateDirectory(Server.MapPath(pdfExportPath));
                        }

解决方案

Try the code below and see if you get the same error.

string path = Server.MapPath(pdfExportPath);
if (!Directory.Exists(path))
{
    Directory.CreateDirectory(path);
}

using (File.Create(Path.Combine(path, "Test.txt")));

if (Directory.Exists(path))
{
    Directory.Delete(path, true);
}


Can you delete a directory manually on that server?
If not, check the access rights for the account you are using.

It is also a bit confusing as you used different paths in the different code segments.
Is this intentional or a mistake?


这篇关于如何使用directory.delete创建一个具有完整访问权限的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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