Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Long File name / path issues #176

Open
bucrepus opened this issue Nov 2, 2022 · 2 comments
Open

Long File name / path issues #176

bucrepus opened this issue Nov 2, 2022 · 2 comments

Comments

@bucrepus
Copy link

bucrepus commented Nov 2, 2022

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.

@altbodhi
Copy link

altbodhi commented Nov 4, 2022

May be this will useful C# long path

@ApoIIy0n
Copy link

ApoIIy0n commented Jan 31, 2023

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}";
  }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants