0

I try to zip three files which I place in my temporary files directory (%temp%). When zipping them with SevenZipSharp I get a zip file with an unnamed folder in it. Within this folder I have my three files but I need the files to be in the root of the Zip. What am I missing here, what am I doing wrong?

public void ZipFiles(String[] files, String absoluteDestination)
{
    List<String> createdFiles = HandleFileIgnore(files);

    System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("de-DE");
    SevenZipCompressor compressor = new SevenZipCompressor(m_TempPath);
    compressor.ArchiveFormat = m_outArchiveFormat; //OutArchiveFormat.Zip
    compressor.PreserveDirectoryRoot = true; //False doesn't solve the problem
    compressor.Compressing += CompressingProgressChanged;
    int commonrootlenght = FindCommonRoot(files, m_CommonRootFolder); //if no commonRootFolder is set it will return -1
    CompressFilesFromRoot(files, absoluteDestination, compressor, commonrootlenght);
    RemoveCreatedFiles(createdFiles);
}

private static void CompressFilesFromRoot(String[] files, String absoluteDestination, SevenZipCompressor compressor, int commonrootlenght)
{
    if (commonrootlenght < 0)
    {
        compressor.CompressFiles(absoluteDestination, files);
    }
    else
    {
        compressor.CompressFiles(absoluteDestination, commonrootlenght, files);
    }
}

enter image description here

Bongo
  • 2,933
  • 5
  • 36
  • 67

1 Answers1

0

It seems that SevenZipSharp couldn't handle 8.3 file paths. My folder name was

C:\Users\XKC-ML~1\AppData\Local\Temp\ApplicationFolder

I simply used

archivePath = Path.GetFullPath(archivePath);

and that did the trick.

Edit: The bug is solved -> https://github.com/squid-box/SevenZipSharp/issues/102

Bongo
  • 2,933
  • 5
  • 36
  • 67