1

I want to compress the directory. But the directory node length is exceeds 250 character so i received a long path error. Please any one help me resolve this issue.

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);

Error : "The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters."

  • i think if possible you need to shorten the source path and destination folder path to something like "D:\\Test\CompressFoderNameMoreThan255Characters\test1" You may look here[https://stackoverflow.com/questions/45549888/how-to-shorten-a-path-in-c-sharp-and-keep-it-valid] – Gnyasha Sep 16 '19 at 11:52
  • Thanks. But this is not applied my process. – Rajesh Kumar C Sep 16 '19 at 13:08

0 Answers0