-1

I'm trying to extract some files from a Zip file, but the FastZip.ExtractZip method I was using is having some issues, for example:

Output location: C:\testing\output\

File 1: PhysicalMemory/idx - this is a file, but is created as a directory
File 2: c:/pagefile.sys/00000052 - This is a directory, but is created as a file
File 3: c:/pagefile.sys/00000052/index - This is a file, but is created as a directory

I'm not sure how to correctly identify these as files or directories, as some of the files don't have file extensions, which the FastZip package seems to use to identify files.

The ZipEntry class has a isDirectory method, but it's returning false for every entry, so I can't use that.

Does anyone have any suggestions on how to approach this?

Tony
  • 3,587
  • 8
  • 44
  • 77
  • How do YOU know these entries are wrong? How are you going to write code that determines which entry is right or wrong? Either way, I suspect you are going to have to modify the Zip library you are using. – Neil Jan 29 '19 at 11:17
  • 3
    Some code might be useful. – Patrick Hofman Jan 29 '19 at 11:17
  • I know the correct path as I've got a full listing of the contents of the zip – Tony Jan 29 '19 at 11:19
  • You can [see how this is implemented](https://github.com/icsharpcode/SharpZipLib/blob/4f541a404f324bd882bc1e8ecd1182c05909b08a/src/ICSharpCode.SharpZipLib/Zip/ZipEntry.cs#L1202-L1214). It expects the entry to end in `\ ` or have certain attributes. Have you tried the built-in [`ZipFile.ExtractToDirectory`](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.zipfile.extracttodirectory?view=netframework-4.7.2)? – Charles Mager Jan 29 '19 at 11:22
  • You have a `pagefile.sys` that is a folder ?? – bommelding Jan 29 '19 at 11:24
  • Yes, pagefile.sys in this instance is a directory. The zip contains data taken from a RAM snapshot – Tony Jan 29 '19 at 11:25

1 Answers1

1

Write your own is directory method to establish file or directory

    public bool isDirectory(string path)
    {
    FileAttributes attr = File.GetAttributes(path);

    if (attr.HasFlag(FileAttributes.Directory))
        return true;
    else
        return false;
    }
Mike
  • 171
  • 1
  • 7
  • I'm not that confident this will solve it given the [current implementation](https://github.com/icsharpcode/SharpZipLib/blob/4f541a404f324bd882bc1e8ecd1182c05909b08a/src/ICSharpCode.SharpZipLib/Zip/ZipEntry.cs#L1202-L1214) appears to do something equivalent. – Charles Mager Jan 29 '19 at 11:26
  • 1
    Good idea, but this requires the file to already be on disk in order for it to be checked. – Tony Jan 29 '19 at 11:28