简体   繁体   中英

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

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."}

Should I first create a.pdf file and then to use or I'm missing something else.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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