使用7zip压缩长路径目录不起作用

时间:2019-09-16 11:35:17

标签: c# directory 7zip

我想压缩目录。但是目录节点的长度超过了250个字符,因此我收到了一条长路径错误。请任何人帮助我解决此问题。

string source=@"D:\\Test\CompressFoderNameMoreThan255Characters\CompressFoderNameMoreThan255CharactersCompressFoderNameMoreThan255CharactersCompressNameMoreThan255Characters\CompressNameMoreThan255CharactersCompressData\CompressData\CompressData\CompressData\CompressData\CompressData\test1\test"
string destination=@"D:\\Test\CompressFoderNameMoreThan255Characters\CompressFoderNameMoreThan255CharactersCompressFoderNameMoreThan255CharactersCompressNameMoreThan255Characters\CompressNameMoreThan255CharactersCompressData\CompressData\CompressData\CompressData\CompressData\CompressData\test1";
string fileName="compFile.7z";
                Setup7zip();
                SevenZipCompressor.SetLibraryPath(@"C:\Program Files\7-Zip\7z.dll");
                SevenZipCompressor compressor = new SevenZipCompressor();
                compressor.ArchiveFormat = OutArchiveFormat.SevenZip;
                compressor.CompressionLevel = SevenZip.CompressionLevel.Normal;
                compressor.CompressionMode = SevenZip.CompressionMode.Create;
                compressor.CompressionMethod = SevenZip.CompressionMethod.Lzma2;
                compressor.TempFolderPath = System.IO.Path.GetTempPath();


                if (!Directory.Exists(destination))
                    Directory.CreateDirectory(destination);



                compressor.CompressDirectory(source, destination+ fileName);

错误:“指定的路径,文件名或两者都太长。完全限定的文件名必须少于260个字符,目录名称必须少于248个字符。”

0 个答案:

没有答案