Exemplo n.º 1
0
        /// <summary>
        /// Checks weather the given file is the Cabinet file or not
        /// </summary>
        /// <param name="path">Path to cabinet file</param>
        /// <returns>TRUE if its cabinet</returns>
        public static bool IsCabinetFile(string path)
        {
            using (CAB.CabDecompressor deComp = new CAB.CabDecompressor())
            {
                using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
                {
                    CAB.FdiCabinetInfo cabInfo = new CAB.FdiCabinetInfo();

                    if (deComp.IsCabinetFile(fs, cabInfo))
                    {
                        return(true);
                    }
                    return(false);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks weather the given file is the Cabinet file or not
        /// </summary>
        /// <param name="path">Path to cabinet file</param>
        /// <returns>TRUE if its cabinet</returns>
        public static bool IsCabinetFile(string path)
        {
            using (CAB.CabDecompressor deComp = new CAB.CabDecompressor())
            {
                using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
                {
                    CAB.FdiCabinetInfo cabInfo = new CAB.FdiCabinetInfo();

                    if (deComp.IsCabinetFile(fs, cabInfo))
                    {

                        return true;
                    }
                    return false;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Extracts the Manifest.xml file from the Cabinet package
        /// </summary>
        /// <param name="cabinetFullPath">Full path to the cabinet</param>
        /// <param name="destPath">Destination of Manifest.xml</param>
        /// <returns></returns>
        public string ExtractManifest(string cabinetFullPath,string destPath)
        {
            destinationDirectory=destPath;
            using (CAB.CabDecompressor decomp = new CAB.CabDecompressor())
            {

                // setup event handlers
                // decomp.NotifyCabinetInfo += new CAB.NotifyEventHandler(decomp_NotifyCabinetInfo);
                 decomp.NotifyCloseFile += decomp_NotifyCloseFile;
                decomp.NotifyCopyFile += decomp_NotifyCopyFile;
                //decomp.NotifyEnumerate += new CAB.NotifyEventHandler(decomp_NotifyEnumerate);
                //decomp.NotifyNextCabinet += new CAB.NotifyEventHandler(decomp_NotifyNextCabinet);
                //decomp.NotifyPartialFile += new CAB.NotifyEventHandler(decomp_NotifyPartialFile);

                CAB.FdiCabinetInfo cabInfo = new CAB.FdiCabinetInfo();

                using (FileStream fs = new FileStream(cabinetFullPath, FileMode.Open, FileAccess.Read))
                {
                    if (!decomp.IsCabinetFile(fs, cabInfo))
                    {
                        throw new NotValidCabinetException();
                    }
                }

                // extract path and filename
                //string cabinetPath = Path.GetDirectoryName(cabinetFullPath);
               // if (cabinetPath != string.Empty)
                    //cabinetPath = cabinetPath + Path.DirectorySeparatorChar;

                // let's copy some files!
                if (!decomp.ExtractFiles(cabinetFullPath))
                {
                    throw new IOException();

                }
                if (!_manifestFound)
                {
                    throw new ManifestNotFoundException();
                }

                return destinationDirectory + Constants.manifestFileName;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Extracts the Manifest.xml file from the Cabinet package
        /// </summary>
        /// <param name="cabinetFullPath">Full path to the cabinet</param>
        /// <param name="destPath">Destination of Manifest.xml</param>
        /// <returns></returns>
        public string ExtractManifest(string cabinetFullPath, string destPath)
        {
            destinationDirectory = destPath;
            using (CAB.CabDecompressor decomp = new CAB.CabDecompressor())
            {
                // setup event handlers
                // decomp.NotifyCabinetInfo += new CAB.NotifyEventHandler(decomp_NotifyCabinetInfo);
                decomp.NotifyCloseFile += decomp_NotifyCloseFile;
                decomp.NotifyCopyFile  += decomp_NotifyCopyFile;
                //decomp.NotifyEnumerate += new CAB.NotifyEventHandler(decomp_NotifyEnumerate);
                //decomp.NotifyNextCabinet += new CAB.NotifyEventHandler(decomp_NotifyNextCabinet);
                //decomp.NotifyPartialFile += new CAB.NotifyEventHandler(decomp_NotifyPartialFile);

                CAB.FdiCabinetInfo cabInfo = new CAB.FdiCabinetInfo();

                using (FileStream fs = new FileStream(cabinetFullPath, FileMode.Open, FileAccess.Read))
                {
                    if (!decomp.IsCabinetFile(fs, cabInfo))
                    {
                        throw new NotValidCabinetException();
                    }
                }

                // extract path and filename
                //string cabinetPath = Path.GetDirectoryName(cabinetFullPath);
                // if (cabinetPath != string.Empty)
                //cabinetPath = cabinetPath + Path.DirectorySeparatorChar;

                // let's copy some files!
                if (!decomp.ExtractFiles(cabinetFullPath))
                {
                    throw new IOException();
                }
                if (!_manifestFound)
                {
                    throw new ManifestNotFoundException();
                }

                return(destinationDirectory + Constants.manifestFileName);
            }
        }