删除目录时出现问题 - 拒绝访问 [英] Problem deleting Directory - access denied

查看:140
本文介绍了删除目录时出现问题 - 拒绝访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从C:复制Windows目录。开车到E:驾驶。当我们尝试从C#应用程序中删除此目录时,应用程序将抛出访问被拒绝的文件。例外。



如果我们尝试手动删除它,那么它会被成功删除。

解决方案

取决于关于您的应用程序如何在某种程度上运行:如果它是由您的用户直接启动,那么它将以您的用户权限运行。如果它以某种其他方式启动 - 例如服务,或者来自不同的应用程序,那么它将获得不同的权限,因为它不以用户身份运行。



您可以通过提升应用程序或在创建文件夹时更改文件夹的访问权限来解决此问题。


可能是您的应用程序在运行时您要删除的文件夹。这也行不通。



祝你好运!


我无法想象这个目录内容的副本可能会有用。它不会在另一个驱动器上安装Windows。 Windows操作系统并非都放在此目录中。此外,即使实际加载并启动了相同版本的Windows,此目录中的某些文件也可能无法在其他位置工作。



-SA

I am copying Windows directory from "C:" drive to "E:" drive. When we try to delete this directory from C# application then application throws "Access denied file" exception.

If we try to delete it manually, then it gets deleted successfully.

解决方案

Depends on how your app is running to an extent: if it is started directly by your user then it runs with your user permissions. If it is started in some other way - as a service, or from a different application for example, then it will get different permissions as it doesn't run as the user.

You may be able to get round this by elevating your app, or by changing the access permissions on the folder when it is created.


Might be that your application in running in the folder you are trying to delete. That won't work either.

Good luck!


I cannot imagine that the copy of the content of this directory can ever be useful. It' won't make Windows installed on the other drive. Windows OS is not all put to this directory. Moreover, some files in this directory may not work in another location even if the same version of Windows is actually loaded and started.

—SA


这篇关于删除目录时出现问题 - 拒绝访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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