简体   繁体   English

WriteAllBytes-拒绝访问路径

[英]WriteAllBytes - Access to the path is denied

I have pdf file as byte array inside myObject.PdfFile and I'm trying to save this inside hdd using write all bytes 我在myObject.PdfFile中有pdf文件作为字节数组,我正在尝试使用写入所有字节将其保存在hdd中

System.IO.File.WriteAllBytes(@"C:\a.pdf", myObject.PdfFile);

using this I'm getting following exception 使用这个我得到以下异常

{"Access to the path 'C:\\a.pdf' is denied."} {“拒绝访问路径'C:\\ a.pdf'。”}

Should I first create a.pdf file and then to use or I'm missing something else. 我应该首先创建一个.pdf文件然后使用还是我遗漏了其他东西。

That is to be expected. 这是可以预料的。 Standard user does not have rights to create files at the root of the system volume. 标准用户无权在系统卷的根目录下创建文件。 Save the file somewhere else where you do have rights. 将文件保存在您拥有权限的其他位置。 For instance, somewhere under the user profile. 例如,在用户个人资料下的某处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM