// ComHelper.cs // ------------------------------------------------------------------ // // Copyright (c) 2009 Dino Chiesa. // All rights reserved. // // This code module is part of DotNetZip, a zipfile class library. // // ------------------------------------------------------------------ // // This code is licensed under the Microsoft Public License. // See the file License.txt for the license details. // More info on: http://dotnetzip.codeplex.com // // ------------------------------------------------------------------ // // last saved (in emacs): // Time-stamp: <2011-June-13 17:04:06> // // ------------------------------------------------------------------ // // This module defines a COM Helper class. // // Created: Tue, 08 Sep 2009 22:03 // using Interop=System.Runtime.InteropServices; namespace OfficeOpenXml.Packaging.Ionic.Zip { /// /// This class exposes a set of COM-accessible wrappers for static /// methods available on the ZipFile class. You don't need this /// class unless you are using DotNetZip from a COM environment. /// [System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d0000F")] [System.Runtime.InteropServices.ComVisible(true)] #if !NETCF [System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)] #endif internal class ComHelper { /// /// A wrapper for ZipFile.IsZipFile(string) /// /// The filename to of the zip file to check. /// true if the file contains a valid zip file. public bool IsZipFile(string filename) { return ZipFile.IsZipFile(filename); } /// /// A wrapper for ZipFile.IsZipFile(string, bool) /// /// /// We cannot use "overloaded" Method names in COM interop. /// So, here, we use a unique name. /// /// The filename to of the zip file to check. /// true if the file contains a valid zip file. public bool IsZipFileWithExtract(string filename) { return ZipFile.IsZipFile(filename, true); } #if !NETCF /// /// A wrapper for ZipFile.CheckZip(string) /// /// The filename to of the zip file to check. /// /// true if the named zip file checks OK. Otherwise, false. public bool CheckZip(string filename) { return ZipFile.CheckZip(filename); } /// /// A COM-friendly wrapper for the static method . /// /// /// The filename to of the zip file to check. /// /// The password to check. /// /// true if the named zip file checks OK. Otherwise, false. public bool CheckZipPassword(string filename, string password) { return ZipFile.CheckZipPassword(filename, password); } /// /// A wrapper for ZipFile.FixZipDirectory(string) /// /// The filename to of the zip file to fix. public void FixZipDirectory(string filename) { ZipFile.FixZipDirectory(filename); } #endif /// /// A wrapper for ZipFile.LibraryVersion /// /// /// the version number on the DotNetZip assembly, formatted as a string. /// public string GetZipLibraryVersion() { return ZipFile.LibraryVersion.ToString(); } } }