Long File name / path issues
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.
May be this will useful C# long path
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}";
}