问题描述
我试图写一个文件到一个目录存在,是由我在创建G:\\
即不是系统目录或在根驱动器
像这样
I am trying to write a file to a directory that exists and is created by me in G:\\
i.e. not a system directory or in root drive
like this
File.WriteAllBytes(directoryPath.Replace("wav", "mp3"), asBytesArray);
但是,这是我抛出这个异常:
But this is throwing me this exception:
An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
Additional information: Access to the path 'G:\Song' is denied.
我该如何解决这个问题呢?请帮帮忙!
How can i solve this issue? Please help!
这是当我从的Visual Studio
调试来了,我不知道如何给它正在运行的调试应用程序的管理权限
This is coming while I am debugging from Visual Studio
and i am not sure how to give administrative rights to the application which is being run as a debug
推荐答案
这通常意味着,要么有一个文件夹命名为G:\歌,所以你不能替换目录一个文件,或者您的Windows用户帐户不具备的许可以写入到该驱动器。
This usually means that either there is a folder named "G:\Song", so you can't replace a directory with a file, or that your windows user account doesn't have permission to write to that drive.
在驱动器上单击鼠标右键,并期待在安全权限,以确保您有权限。此外,还要确保该驱动器不是只读的,作为一个写保护SD卡或闪存驱动器的情况下。
Right-click on the drive and look at security permissions to be sure you have permission. Also, make sure the drive is not readonly, as in the case of a write-protected SD card or flash drive.
这篇关于类型'System.UnauthorizedAccessException的“未处理的异常在mscorlib.dll中发生:访问路径...被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!