SevenZipSharp icon indicating copy to clipboard operation
SevenZipSharp copied to clipboard

Long File name / path issues

Open bucrepus opened this issue 3 years ago • 2 comments

Does this support long paths / filenames like the 7Zip GUI or command line does? When I try to pass a folder(s) to zip that has a long path it errors out with a can't find part of the path error. Passing a directory with normal < 260 char paths works just fine. The normal 7Zip Gui can zip directories with long paths with no issue. Windows OS

Dim sz As New SevenZip.SevenZipCompressor sz.CompressionLevel = SevenZip.CompressionLevel.Ultra sz.CompressionMode = SevenZip.CompressionMode.Create sz.CompressionMethod = SevenZip.CompressionMethod.Default sz.CompressDirectory("f:\mycomputer", "f:\testy.7z") *****works OK as long as the paths are not long..

manually zipping it with 7zip works OK.

bucrepus avatar Nov 02 '22 14:11 bucrepus

May be this will useful C# long path

altbodhi avatar Nov 04 '22 12:11 altbodhi

Does this support long paths / filenames like the 7Zip GUI or command line does? When I try to pass a folder(s) to zip that has a long path it errors out with a can't find part of the path error. Passing a directory with normal < 260 char paths works just fine. The normal 7Zip Gui can zip directories with long paths with no issue. Windows OS

Dim sz As New SevenZip.SevenZipCompressor sz.CompressionLevel = SevenZip.CompressionLevel.Ultra sz.CompressionMode = SevenZip.CompressionMode.Create sz.CompressionMethod = SevenZip.CompressionMethod.Default sz.CompressDirectory("f:\mycomputer", "f:\testy.7z") *****works OK as long as the paths are not long..

manually zipping it with 7zip works OK.

this should work for you.

  // if the path of the file including the file name exceeds 256 characters we need to change it's prefix.
  if (file.Length > 256)
  {
      // prefix depends if it's on a share or on a local disk
      longFile = (file[0] == '\\') ? file.Replace("\\\\", @"\\?\UNC\") : $@"\\?\{file}";
  }

ApoIIy0n avatar Jan 31 '23 14:01 ApoIIy0n