We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Zip DetectFileFormat

Where’s the DetectFileFormat function for Aspose.Zip to detect and distinguish the different Zip supported formats? Usage sample?

Hello @australian.dev.nerds, we have not such a function.
Generally, you can detect an archive format basing on file extension. If you open the archive with incorrect class, e. g. zip archive with RarArchive class you’ll get an exception.

Heart breaking, to not to have the lovely DetectFileFormat for Aspose Zip! :frowning:

Yes. Here is how you can detect archive format by extension:

FileInfo fi = new FileInfo(filename);
switch (fi.Extension)
        case ".zip":
            using (Aspose.Zip.Archive zip = new (filename))
            { ... }
        case ".rar":
            using (Aspose.Zip.Rar.RarArchive rar = new (filename))
            { ... }

Hello and thanks for your help, btw, not sure if the select case was serious or an input josh :smiley:
Anyway, currently testing Aspose Email trial and found that some other SDKs also have DetectFileFormat, so please register a feature request for Zip :: DetectFileFormat to detect file format without loading / creating the file actually.

We opened a ZIPNET-937 issue for this feature and let you know on any progress with it. This won’t be soon.

1 Like

Hello and thanks for consideration, how late you mean, perhaps by the end of Jan 2023?

The end of Jan 2023 seems realistic.