/// <summary> /// Checks a file to see if it is a valid zip file. /// </summary> /// /// <remarks> /// <para> /// This method opens the specified zip file, reads in the zip archive, /// verifying the ZIP metadata as it reads. /// </para> /// /// <para> /// If everything succeeds, then the method returns true. If anything fails - /// for example if an incorrect signature or CRC is found, indicating a /// corrupt file, the the method returns false. This method also returns /// false for a file that does not exist. /// </para> /// /// <para> /// If <paramref name="testExtract"/> is true, as part of its check, this /// method reads in the content for each entry, expands it, and checks CRCs. /// This provides an additional check beyond verifying the zip header and /// directory data. /// </para> /// /// <para> /// If <paramref name="testExtract"/> is true, and if any of the zip entries /// are protected with a password, this method will return false. If you want /// to verify a <c>ZipFile</c> that has entries which are protected with a /// password, you will need to do that manually. /// </para> /// /// </remarks> /// /// <param name="zipFileName">The zip file to check.</param> /// <param name="testExtract">true if the caller wants to extract each entry.</param> /// <returns>true if the file contains a valid zip file.</returns> public static bool IsZipFile(string zipFileName, bool testExtract) { return(ZipFileExtensions.IsZipFile(zipFileName, testExtract)); }
/// <summary> /// Checks the given file to see if it appears to be a valid zip file. /// </summary> /// <remarks> /// /// <para> /// Calling this method is equivalent to calling <see cref="IsZipFile(string, /// bool)"/> with the testExtract parameter set to false. /// </para> /// </remarks> /// /// <param name="zipFileName">The file to check.</param> /// <returns>true if the file appears to be a zip file.</returns> public static bool IsZipFile(string zipFileName) { return(ZipFileExtensions.IsZipFile(zipFileName)); }