简体   繁体   中英

Access to the path “somepath” is denied."

When i execute this code in my C# console application, it throws "Access to the path "somepath" is denied" on using line.

This is my code.

static public PdfDocument Open(string PdfPath)
{
    using (var fileStream = new FileStream(PdfPath, FileMode.Open, FileAccess.Read))
    {
        int len = (int)fileStream.Length;
        Byte[] fileArray = new Byte[len];
        fileStream.Read(fileArray, 0, len);
        return Open(fileArray);
    }
}

What is going wrong. Any thought? By the way I logged in as system admin and I have full control in the given folder.

也许文件是由另一个进程以独占写入模式打开的。

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