csharp中的访问被拒绝异常 [英] Access denied exception in csharp

查看:156
本文介绍了csharp中的访问被拒绝异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有文件复制程序,它从c驱动器以外的所有驱动器复制文件。想要复制文件C驱动器导致访问被拒绝的例外通过。

如何处理这个问题所以我也可以从C盘复制。

I have file copy program which copy the file from all the drive except c drive.Trying to copy the file C drive causes 'Access denied exception' to through.
How to deal with this problem so I will able to copy from C drive also.

推荐答案

您必须以管理员身份运行您的应用程序。为此,右键单击可执行文件,然后单击以管理员身份运行。



如果要从Visual Studio以管理员身份启动应用程序,请运行VS作为管理员。然后,当您从VS启动时,您的应用将以管理员身份自动运行。
You have to run your application as Administrator. To do that, right-click on the executable and click "Run As Administrator".

In case you want to launch your application as Administrator from Visual Studio, run VS as Administrator. Then your app will be automatically running as Administrator when you launch it from VS.


这篇关于csharp中的访问被拒绝异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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