【问题标题】:How to fix System.UnauthorizedAccessException when decompressing bz2 file?解压bz2文件时如何修复System.UnauthorizedAccessException?
【发布时间】:2011-07-15 20:06:09
【问题描述】:

我正在尝试使用 ICSharpCode.SharpZipLib 通过代码解压缩 bz2 文件。

似乎无论我在哪里制作文件,即使我对它有 FULL ACCESS 控制权,我仍然会收到此异常。非常感谢任何帮助。

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# permissions sharpziplib


    【解决方案1】:

    您的代码无权在您的桌面上创建新路径。 检查"C:\\Users\\mike\\Desktop\\Decompressed" 的权限。

    【讨论】:

    • 那你为什么要使用这个:File.Create(path)?您的代码是否拥有该文件的权限?
    【解决方案2】:

    也许,你应该这样写:

    string decompressPath = "C:\\Users\\mike\\Desktop\\Decompressed\\opinions.tsv";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-28
      • 2011-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-17
      • 1970-01-01
      相关资源
      最近更新 更多