Пример #1
0
        public static Collection <CabinetFileInfo> GetCabFiles(string cabFileName)
        {
            CabLib.Extract cabExtract = new CabLib.Extract();

            CabParser parser = new CabParser(cabExtract, cabFileName);

            try
            {
                parser.PopulateFileData();
                return(parser.FileInfo);
            }
            catch (System.Exception)
            {
                return(null);
            }
            finally
            {
                parser.Dispose();
            }
        }
Пример #2
0
        public static void ExtractCab(string cabFile, string folder)
        {
            if (cabFile == null)
            {
                throw new ArgumentNullException("cabFile");
            }
            if (folder == null)
            {
                throw new ArgumentNullException("folder");
            }

            if (!File.Exists(cabFile))
            {
                throw new ArgumentException("File does not exist: " + cabFile, "cabFile");
            }
            if (!Directory.Exists(folder))
            {
                throw new ArgumentException("Folder does not exist: " + folder, "folder");
            }

            CabLib.Extract cabExtract = new CabLib.Extract();

            try
            {
                // Now extract into subdirectory and the corresponding subdirectories in the CAB file
                cabExtract.ExtractFile(cabFile, folder);
            }
            catch (System.Exception ex)
            {
                if (ex.Message.Contains("The file is not a cabinet") || ex.Message.Contains("corrupt") || ex.Message.Contains("Corrupt"))
                {
                    // Must be a dud cab file. Delete it so the next resync causes a download again.
                    File.Delete(cabFile);
                }
                throw;
            }
        }
Пример #3
0
 public CabParser(CabLib.Extract cabExtract, String cabFileName)
 {
     m_CabExtract  = cabExtract;
     m_CabFileName = cabFileName;
 }