![](/img/trans.png)
[英]How to fix this System.UnauthorizedAccessException? C#
[英]How to fix System.UnauthorizedAccessException when decompressing bz2 file?
我試圖通過使用 ICSharpCode.SharpZipLib 的代碼解壓縮 bz2 文件。
似乎無論我在哪里制作文件,即使我可以完全訪問它,我仍然會收到此異常。 非常感謝任何幫助。
using System;
using System.IO;
using ICSharpCode.SharpZipLib.BZip2;
namespace decompressor
{
class MainClass
{
public static void Main(string[] args)
{
string filePath = "C:\\FreeBase\\opinions.tsv.bz2";
string decompressPath = "C:\\Users\\mike\\Desktop\\Decompressed";
Console.WriteLine("Decompressing {0} to {1}", file, path);
BZip2.Decompress(File.OpenRead(filePath),File.OpenWrite(decompressPath), true);
}
}
}
您的代碼無權在桌面上創建新路徑。 檢查"C:\\Users\\mike\\Desktop\\Decompressed"
的權限。
也許,你應該這樣寫:
string decompressPath = "C:\\Users\\mike\\Desktop\\Decompressed\\opinions.tsv";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.