public void PopulateFileData() { m_CabExtract.evBeforeCopyFile += new Extract.delBeforeCopyFile(this.BeforeCopyFileCallback); // Install a delegate callback to stop the actual extraction. m_CabExtract.ExtractFile(m_CabFileName, Path.GetTempPath()); }
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; } }