ExtractZip() public méthode

Extract the contents of a zip file held in a stream.
public ExtractZip ( Stream inputStream, string targetDirectory, Overwrite overwrite, ConfirmOverwriteDelegate confirmDelegate, string fileFilter, string directoryFilter, bool restoreDateTime, bool isStreamOwner ) : void
inputStream Stream The seekable input stream containing the zip to extract from.
targetDirectory string The directory to save extracted information in.
overwrite Overwrite The style of overwriting to apply.
confirmDelegate ConfirmOverwriteDelegate A delegate to invoke when confirming overwriting.
fileFilter string A filter to apply to files.
directoryFilter string A filter to apply to directories.
restoreDateTime bool Flag indicating whether to restore the date and time for extracted files.
isStreamOwner bool Flag indicating whether the inputStream will be closed by this method.
Résultat void
Exemple #1
1
 /// <summary>
 /// 解压zip文件
 /// </summary>
 /// <param name="_zipFile">需要解压的zip路径+名字</param>
 /// <param name="_outForlder">解压路径</param>
 public void UnZipFile(string _zipFile, string _outForlder)
 {
     if (Directory.Exists(_outForlder))
         Directory.Delete(_outForlder, true);
     Directory.CreateDirectory(_outForlder);
     progress = progressOverall = 0;
     Thread thread = new Thread(delegate ()
     {
         int fileCount = (int)new ZipFile(_zipFile).Count;
         int fileCompleted = 0;
         FastZipEvents events = new FastZipEvents();
         events.Progress = new ProgressHandler((object sender, ProgressEventArgs e) =>
         {
             progress = e.PercentComplete;
             if (progress == 100) { fileCompleted++; progressOverall = 100 * fileCompleted / fileCount; }
         });
         events.ProgressInterval = TimeSpan.FromSeconds(progressUpdateTime);
         events.ProcessFile = new ProcessFileHandler(
             (object sender, ScanEventArgs e) => { });
         FastZip fastZip = new FastZip(events);
         fastZip.ExtractZip(_zipFile, _outForlder, "");
     });
     thread.IsBackground = true;
     thread.Start();
 }
        private static bool ExtractZipArchive(string archive, string destination, FastZip fz)
        {

            DirectoryInfo newdirFI;

            if (!Directory.Exists(destination))
            {
                newdirFI = Directory.CreateDirectory(destination);

                if (!Directory.Exists(newdirFI.FullName))
                {
                    //MessageBox.Show("Directory " + destination + " could not be created.");
                    return false;
                }
            }
            else newdirFI = new DirectoryInfo(destination);


            try
            {
                Thread.Sleep(500);
                fz.ExtractZip(archive, newdirFI.FullName, "");
            }
            catch (Exception e)
            {
                Debugger.LogMessageToFile("The archive " + archive + " could not be extracted to destination " + destination +
                                          ". The following error ocurred: " + e);
            }



            return true;
        }
        public ReleasePackage CreateDeltaPackage(ReleasePackage basePackage, ReleasePackage newPackage, string outputFile)
        {
            Contract.Requires(basePackage != null);
            Contract.Requires(!String.IsNullOrEmpty(outputFile) && !File.Exists(outputFile));

            if (basePackage.Version > newPackage.Version) {
                var message = String.Format(
                    "You cannot create a delta package based on version {0} as it is a later version than {1}",
                    basePackage.Version,
                    newPackage.Version);
                throw new InvalidOperationException(message);
            }

            if (basePackage.ReleasePackageFile == null) {
                throw new ArgumentException("The base package's release file is null", "basePackage");
            }

            if (!File.Exists(basePackage.ReleasePackageFile)) {
                throw new FileNotFoundException("The base package release does not exist", basePackage.ReleasePackageFile);
            }

            if (!File.Exists(newPackage.ReleasePackageFile)) {
                throw new FileNotFoundException("The new package release does not exist", newPackage.ReleasePackageFile);
            }

            string baseTempPath = null;
            string tempPath = null;

            using (Utility.WithTempDirectory(out baseTempPath, null))
            using (Utility.WithTempDirectory(out tempPath, null)) {
                var baseTempInfo = new DirectoryInfo(baseTempPath);
                var tempInfo = new DirectoryInfo(tempPath);

                this.Log().Info("Extracting {0} and {1} into {2}", 
                    basePackage.ReleasePackageFile, newPackage.ReleasePackageFile, tempPath);

                var fz = new FastZip();
                fz.ExtractZip(basePackage.ReleasePackageFile, baseTempInfo.FullName, null);
                fz.ExtractZip(newPackage.ReleasePackageFile, tempInfo.FullName, null);

                // Collect a list of relative paths under 'lib' and map them
                // to their full name. We'll use this later to determine in
                // the new version of the package whether the file exists or
                // not.
                var baseLibFiles = baseTempInfo.GetAllFilesRecursively()
                    .Where(x => x.FullName.ToLowerInvariant().Contains("lib" + Path.DirectorySeparatorChar))
                    .ToDictionary(k => k.FullName.Replace(baseTempInfo.FullName, ""), v => v.FullName);

                var newLibDir = tempInfo.GetDirectories().First(x => x.Name.ToLowerInvariant() == "lib");

                foreach (var libFile in newLibDir.GetAllFilesRecursively()) {
                    createDeltaForSingleFile(libFile, tempInfo, baseLibFiles);
                }

                ReleasePackage.addDeltaFilesToContentTypes(tempInfo.FullName);
                fz.CreateZip(outputFile, tempInfo.FullName, true, null);
            }

            return new ReleasePackage(outputFile);
        }
Exemple #4
0
        public static void AssemblyInit(TestContext context)
        {
            File.WriteAllText("NorthwindTranslation_VfpQueryProvider.base", Properties.Resources.NorthwindTranslationXml);
            File.WriteAllBytes("NorthwindVfp.zip", Properties.Resources.NorthwindVfpZip);
            File.WriteAllBytes("DecimalTable.zip", Properties.Resources.DecimalTableZip);

            var zip = new FastZip();
            zip.ExtractZip("NorthwindVfp.zip", context.TestDeploymentDir, string.Empty);
            zip.ExtractZip("DecimalTable.zip", Path.Combine(context.TestDeploymentDir, "Decimal"), string.Empty);

            Directory.CreateDirectory(BackupPath);
            CopyData(DbcPath, BackupPath);

            VfpClientTracing.Tracer = new TraceSource("VfpClient", SourceLevels.Information);
            VfpClientTracing.Tracer.Listeners.Add(new TestContextTraceListener(context));
        }
Exemple #5
0
 private void GetFile()
 {
     var exctractfolder = _localFile.DirectoryName.ToString() + @"\exctract\";
     DownloadFile(_localFile.FullName);
     var zip = new FastZip();
     zip.ExtractZip(_localFile.FullName, exctractfolder, "");
 }
		private void setDbfInfoFromZip(string dbfPath)
		{	
			try
			{	
				//Navigate the Zip to find the files and update their index
				ZipFile zFile = new ZipFile(dbfPath);				
				foreach (ZipEntry ze in zFile) 
				{
					if(ze.Name.ToLower().EndsWith(".dbf"))
					{
						//Extracts the file in temp
						FastZip fz = new FastZip();
						fz.ExtractZip(dbfPath, Path.GetTempPath(),
							ICSharpCode.SharpZipLib.Zip.FastZip.Overwrite.Always,null,"","");
						setDbfInfo(Path.Combine(Path.GetTempPath(),ze.Name));						
					}
				}						
			}
			catch { return; }			


			

            
			
			//TODO: read the sbf data into the datagrid

			//DataTable dt=getInfoFromDBF(dbfPath);			
			//dataGrid1.DataSource=dt;
			//dataGrid1.CaptionText=dbfPath;			
		}
 private void UnzipNewAgentVersion()
 {
     _logger.Log("Unzipping files");
     var fz = new FastZip();
     fz.ExtractZip(Constants.AgentServiceReleasePackage, Constants.AgentServiceUnzipPath, "");
     _logger.Log("Unzipping files complete");
 }
Exemple #8
0
        private static void DownloadAndUpdateSnakeBite(string URL)
        {
            // Download update archive
            using (WebClient w = new WebClient()) w.DownloadFile(URL, "update.dat");

            // Extract archive
            FastZip z = new FastZip();
            z.ExtractZip("update.dat", "_update", "(.*?)");

            // Move update file
            File.Delete("SnakeBite.exe");
            File.Delete("MakeBite.exe");
            File.Delete("GzsTool.Core.dll");
            File.Delete("fpk_dictionary.txt");
            File.Delete("qar_dictionary.txt");
            File.Move("_update/SnakeBite.exe", "SnakeBite.exe");
            File.Move("_update/MakeBite.exe", "MakeBite.exe");
            File.Move("_update/GzsTool.Core.dll", "GzsTool.Core.dll");
            File.Move("_update/fpk_dictionary.txt", "fpk_dictionary.txt");
            File.Move("_update/qar_dictionary.txt", "qar_dictionary.txt");

            // Restart updater
            Process updater = new Process();
            updater.StartInfo.Arguments = "-u";
            updater.StartInfo.UseShellExecute = false;
            updater.StartInfo.FileName = "sbupdater.exe";
            updater.Start();

            Environment.Exit(0);
        }
Exemple #9
0
        public static void unZIP(string srcZip, string detDir)
        {
            string filename = Path.GetFileNameWithoutExtension(srcZip);
            if (detDir == string.Empty)
            {
                detDir = srcZip.Substring(0,srcZip.LastIndexOf("\\"));
            }

            detDir = detDir + "\\" + filename;

            if (!Directory.Exists(detDir))
            {
                 Directory.CreateDirectory(detDir);
            }
            FastZip fastzip = new FastZip();
            //// Create Empty Directory
            fastzip.CreateEmptyDirectories = true;

            try
            {
                fastzip.ExtractZip(srcZip, detDir, string.Empty);
                //MessageBox.Show("ok");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="filename"></param>
        /// <returns>temporary project file name.</returns>
        public string UnzipProject(string filename)
        {
            output = null;
            // Check File
            if (!File.Exists(filename))
                throw new EcellException(string.Format(MessageResources.ErrLoadPrj, filename));

            // Extract zip
            string dir = Path.Combine(Util.GetTmpDir(), Path.GetRandomFileName());
            FastZip fz = new FastZip();
            fz.ExtractZip(filename, dir, null);

            // Check Project File.
            string project = Path.Combine(dir,Constants.fileProjectXML);
            string info = Path.Combine(dir,Constants.fileProjectInfo);
            if(File.Exists(project))
                output = project;
            else if(File.Exists(info))
                output = info;

            if (output == null)
            {
                Directory.Delete(dir);
                throw new EcellException(string.Format(MessageResources.ErrLoadPrj, filename));
            }

            // Return project path.
            return output;
        }
Exemple #11
0
    protected void LinkZip_Click(object sender, EventArgs e)
    {
        if (!YetkiKontrol(pageName + "-Update"))
            return;


        try
        {
            string temaPath = Server.MapPath("~/uploads/temp/temp-uploaded");

            try { Directory.Delete(temaPath, true); }
            catch { }

            if (FU1.PostedFile.ContentType != "application/x-zip-compressed" && FU1.PostedFile.ContentType != "application/octet-stream" && FU1.PostedFile.ContentType != "application/zip" && FU1.PostedFile.ContentType != "application/x-rar-compressed")
            {
                Snlg_Hata.ziyaretci.HataGosterHatali(Resources.admin_language.theme_01, false);
                return;
            }
            if (Path.GetExtension(FU1.FileName).ToLower() != ".zip")
            {
                Snlg_Hata.ziyaretci.HataGosterHatali(Resources.admin_language.theme_02, false);
                return;
            }

            FU1.SaveAs(Server.MapPath("~/uploads/temp/temp-tema.zip"));
            FastZip fz = new FastZip();
            fz.ExtractZip(Server.MapPath("~/uploads/temp/temp-tema.zip"), temaPath, null);
            File.Delete(Server.MapPath("~/uploads/temp/temp-tema.zip"));

            bool exist = false;
            StringBuilder sbHtml = new StringBuilder();
            ListExistsFile(temaPath, sbHtml, 0, ref exist, temaPath);

            if (exist)
            {
                LtrList.Text = sbHtml.ToString();
                Snlg_Hata.ziyaretci.HataGosterHatali(Resources.admin_language.theme_03, false);
            }
            else
                Snlg_Hata.ziyaretci.HataGosterBasarili(Resources.admin_language.theme_04, false);

            if (Directory.Exists(Path.Combine(temaPath, "sql-scripts")))
            {
                string[] sqlFiles = Directory.GetFiles(Path.Combine(temaPath, "sql-scripts"), "*.sql");
                if (sqlFiles.Length > 0)
                    Snlg_Hata.ziyaretci.HataGosterUyari(Resources.admin_language.theme_05.Replace("{0}", sqlFiles.Length.ToString()), false);
                else
                    Snlg_Hata.ziyaretci.HataGosterBasarili(Resources.admin_language.theme_06, false);
            }
            else
                Snlg_Hata.ziyaretci.HataGosterBasarili(Resources.admin_language.theme_07, false);

            divButon.Visible = true;
        }
        catch (Exception exc)
        {
            Snlg_Hata.ziyaretci.HataGosterHatali(Resources.admin_language.theme_08 + exc.Message, false);
            return;
        }
    }
Exemple #12
0
        private static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.Error.WriteLine("Error: not enough arguments");
                Console.Error.WriteLine("Usage: MetroIdeUpdateManager <update zip> <metroide exe> <parent pid>");
                return;
            }
            string zipPath = args[0];
            string exePath = args[1];
            int pid = Convert.ToInt32(args[2]);

            try
            {
                // Wait for Assembly to close
                try
                {
                    Process process = Process.GetProcessById(pid);
                    process.WaitForExit();
                    process.Close();
                }
                catch
                {
                }

                // Extract the update zip
                var fz = new FastZip {CreateEmptyDirectories = true};
                for (int i = 0; i < 5; i++)
                {
                    try
                    {
                        fz.ExtractZip(zipPath, Directory.GetCurrentDirectory(), null);
                        break;
                    }
                    catch (IOException)
                    {
                        Thread.Sleep(1000);
                        if (i == 4)
                        {
                            throw;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Assembly Update Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            try
            {
                File.Delete(zipPath);
            }
            catch
            {
            }

            // Launch "The New iPa... Assembly"
            Process.Start("Assembly://post-update");
        }
 public static void ExtractZipFile(string zipFile, string outputFolder) {
     FastZip fastZip = new FastZip();
     try {
         fastZip.ExtractZip(zipFile, outputFolder, null); // Will always overwrite if target filenames already exist
     } catch (Exception ex) {
         Logger.Error("Extracting Zip failed.", ex);
     }
 }
Exemple #14
0
 public static bool ExtractZip(string filename, string directory)
 {
     FastZip fz = new FastZip();
     fz.CreateEmptyDirectories = true;
     fz.ExtractZip(filename, directory, "");
     fz = null;
     return true;
 }
Exemple #15
0
        public void UnZip()
        {
            string zipPath = "D:/Test.zip";
            string zipDir = "D:/Test2/";

            FastZip fastZip = new FastZip();
            fastZip.ExtractZip(zipPath, zipDir, null);
        }
Exemple #16
0
 /// <summary>
 /// Décompresse entierement un fichier LibreOffice
 /// </summary>
 /// <param name="zipFile"></param>
 /// <param name="destination"></param>
 /// <returns></returns>
 public void extractZip(string zipFile, string destination)
 {
     ICSharpCode.SharpZipLib.Zip.FastZip z = new ICSharpCode.SharpZipLib.Zip.FastZip();
     z.CreateEmptyDirectories     = true;
     z.RestoreAttributesOnExtract = true;
     z.RestoreDateTimeOnExtract   = true;
     z.ExtractZip(zipFile, destination, string.Empty);
 }
Exemple #17
0
        /// <summary>
        /// 解压
        /// </summary>
        public static void decompress(string _localPath, string _zipFileName)
        {
            string zipFileName = _zipFileName; //待解压的目录文件
            string localPath   = _localPath;   //解压后的目录
            // Zip it into a memory stream.
            var zip = new ICSharpCode.SharpZipLib.Zip.FastZip();

            zip.ExtractZip(zipFileName, localPath, string.Empty);
        }
Exemple #18
0
        public static void Unzip(string directory, string zip)
        {
            var package = new FastZip
                              {
                                  CreateEmptyDirectories = true
                              };

            package.ExtractZip(zip, directory, String.Empty);
        }
        public void unZip()
        {
            string zipFileName = @"..\..\..\Sample-Sales-Reports.zip"; // change
            var targetDir = @"..\..\..\Excel";
            FastZip fastZip = new FastZip();
            string fileFilter = null;

            // Will always overwrite if target filenames already exist
            fastZip.ExtractZip(zipFileName, targetDir, fileFilter);
        }
Exemple #20
0
        protected override void ExecuteAction(IFileActionInfo fileActionInfo)
        {
            SourceTargetFilterFileInfo zipFile = fileActionInfo as SourceTargetFilterFileInfo;

            zip.ExtractZip(zipFile.SourceFileName, zipFile.TargetPath, zipFile.FilterFiles);
            foreach (SourceFileInfo f in files)
            {
                f.LockOnExecute(Locker);
            }
        }
Exemple #21
0
        public static void RunWholeProcedure()
        {
            Compile.currentMooegeExePath = Program.programPath + @"\" + @"Repositories\" + ParseRevision.developerName + "-" + ParseRevision.branchName + "-" + ParseRevision.lastRevision + @"\src\Mooege\bin\Debug\Mooege.exe";
            Compile.currentMooegeDebugFolderPath = Program.programPath + @"\" + @"Repositories\" + ParseRevision.developerName + "-" + ParseRevision.branchName + "-" + ParseRevision.lastRevision + @"\src\Mooege\bin\Debug\";
            Compile.mooegeINI = Program.programPath + @"\" + @"Repositories\" + ParseRevision.developerName + "-" + ParseRevision.branchName + "-" + ParseRevision.lastRevision + @"\src\Mooege\bin\Debug\config.ini";

            ZipFile zip = null;
            var events = new FastZipEvents();

            if (ProcessFinder.FindProcess("Mooege") == true)
            {
                ProcessFinder.KillProcess("Mooege");
            }

            FastZip z = new FastZip(events);
            Console.WriteLine("Uncompressing zip file...");
            var stream = new FileStream(Program.programPath + @"\Repositories\" + @"\Mooege.zip", FileMode.Open, FileAccess.Read);
            zip = new ZipFile(stream);
            zip.IsStreamOwner = true; //Closes parent stream when ZipFile.Close is called
            zip.Close();

            var t1 = Task.Factory.StartNew(() => z.ExtractZip(Program.programPath + @"\Repositories\" + @"\Mooege.zip", Program.programPath + @"\" + @"Repositories\", null))
                .ContinueWith(delegate
            {
                //Comenting the lines below because I haven't tested this new way over XP VM or even normal XP.
                //RefreshDesktop.RefreshDesktopPlease(); //Sends a refresh call to desktop, probably this is working for Windows Explorer too, so i'll leave it there for now -wesko
                //Thread.Sleep(2000); //<-This and ^this is needed for madcow to work on VM XP, you need to wait for Windows Explorer to refresh folders or compiling wont find the new mooege folder just uncompressed.
                Console.WriteLine("Uncompress Complete.");
                if (File.Exists(Program.madcowINI))
                {
                    IConfigSource source = new IniConfigSource(Program.madcowINI);
                    String Src = source.Configs["Balloons"].Get("ShowBalloons");

                    if (Src.Contains("1"))
                    {
                        Form1.GlobalAccess.MadCowTrayIcon.ShowBalloonTip(1000, "MadCow", "Uncompress Complete!", ToolTipIcon.Info);
                    }
                }
                Form1.GlobalAccess.Invoke((MethodInvoker)delegate { Form1.GlobalAccess.generalProgressBar.PerformStep(); });
                Compile.compileSource(); //Compile solution projects.
                Form1.GlobalAccess.Invoke((MethodInvoker)delegate { Form1.GlobalAccess.generalProgressBar.PerformStep(); });
                Form1.GlobalAccess.Invoke((MethodInvoker)delegate { Form1.GlobalAccess.generalProgressBar.PerformStep(); });
                Console.WriteLine("[Process Complete!]");
                if (File.Exists(Program.madcowINI))
                {
                    IConfigSource source = new IniConfigSource(Program.madcowINI);
                    String Src = source.Configs["Balloons"].Get("ShowBalloons");

                    if (Src.Contains("1"))
                    {
                        Form1.GlobalAccess.MadCowTrayIcon.ShowBalloonTip(1000, "MadCow", "Process Complete!", ToolTipIcon.Info);
                    }
                }
            });
        }
        public Document ParseDocument(string path)
        {
            using (TempDirectory directory = new TempDirectory())
            {
                FastZip zip = new FastZip();
                zip.ExtractZip(path, directory.ToString(), null);

                Document document = new FileInfoSerializer().Deserialize(Path.Combine(directory.FilePath, FILE_NAME));

                return document;
            }
        }
 /// <summary>
 /// Extracts the zipFile to targetDirectory using the fileFilter
 /// </summary>
 /// <param name="zipFile">The path to the .zip file to extract</param>
 /// <param name="targetDirectory">The directory to extract it to</param>
 /// <param name="fileFilter">regex values semi-colon separated for files to extract (Example @"+\.dat$;-^dummy\.dat$" will extract all .dat files except for dummy.dat</param>
 /// <returns>True if operation completed successfully</returns>
 public static bool ExtractZip(string zipFile, string targetDirectory, string fileFilter = "")
 {
   bool ret = false;
   _error_message = "";
   try
   {
     FastZip fz = new FastZip();
     fz.ExtractZip(zipFile, targetDirectory, fileFilter);
     ret = true;
   }
   catch (Exception e) { _error_message = e.Message; }
   return ret;
 }
Exemple #24
0
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.Error.WriteLine("Error: not enough arguments");
                Console.Error.WriteLine("Usage: AssemblyUpdateManager <update zip> <assembly exe>");
                return;
            }
            string zipPath = args[0];
            string exePath = args[1];

            try
            {
                // Kill retail shit
                Process[] openAssemblys = Process.GetProcessesByName(Path.GetFileName(exePath));
                foreach (Process process in openAssemblys)
                {
                    if (!process.HasExited)
                        process.Kill();
                }

                // Kill dev shit
                openAssemblys = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(exePath) + ".vshost.exe");
                foreach (Process process in openAssemblys)
                {
                    if (!process.HasExited)
                        process.Kill();
                }

                // Extract the update zip
                FastZip fz = new FastZip();
                fz.CreateEmptyDirectories = true;
                fz.ExtractZip(zipPath, Directory.GetCurrentDirectory(), null);
                File.Delete(zipPath);
            }
            catch (Exception ex)
            {
                // Write the exception data to a temporary file and run Assembly again, telling it to display it
                /*string filePath = Path.GetTempFileName();
                File.WriteAllText(filePath, ex.ToString());

                // The --updateError switch tells Assembly to display an exception message read from the text file
                Process.Start(exePath, "--updateError \"" + filePath + "\"");*/

                MessageBox.Show(ex.ToString(), "Assembly Update Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // Launch "The New iPa... Assembly"
            Process.Start(exePath, "/fromUpdater " + Process.GetCurrentProcess().Id);
        }
Exemple #25
0
 /// <summary>
 /// 解压文件
 /// </summary>
 /// <param name="FileToZip">要解压的文件路径</param>
 /// <param name="FileFolderToUnZip">解压到的文件夹路径</param>
 /// <returns>解压文件是否成功</returns>
 public static Boolean UNZipFile(string FileToZip, string FileFolderToUnZip)
 {
     try
     {
         FastZip fastZip = new FastZip();
         fastZip.ExtractZip(FileToZip, FileFolderToUnZip, "");
         return true;
     }
     catch (Exception ex)
     {
         MongoDBLog.LogRecord(ex);
         return false;
     }
 }
        public void UnZip(string zipName, string FolderDestination)
        {
            label1.SafeInvoke(d => d.Text = "Extracting files to folder " + FolderDestination + ". Wait!");
            try
            {
                FastZipEvents zipevents = new FastZipEvents();
                zipevents.ProcessFile = new ProcessFileHandler(ProcessFile);

                FastZip fz = new FastZip(zipevents);
                fz.CreateEmptyDirectories = true;
                fz.ExtractZip(zipName, FolderDestination, "");
            }
            catch { }
        }
        internal static string ConstructSubtitleFilenameAndExtractSubtitle(IMLItem item, string parentPath, string videoFilename,
            FastZip fz, string zipfilePath, out string subtitleFilename,
            out string subtitleExtension)
        {
            subtitleFilename = ConstructExtractedSubtitleFilename
                (item, zipfilePath, out subtitleExtension);

            videoFilename = videoFilename.Substring(0, videoFilename.Length - 4);

            fz.ExtractZip(zipfilePath, parentPath, @"(?i)^.*(?:(?:.srt)|(?:.sub))$");

            Settings.zipfilepath = zipfilePath;

            return videoFilename;
        }
Exemple #28
0
        public static void ExtractFiles(string ZipFile, string OutputDir)
        {
            if (Directory.Exists("_zip")) Directory.Delete("_zip", true);
            string ModRoot = GetModRoot(ZipFile);
            FastZip z = new FastZip();
            z.ExtractZip(ZipFile, "_zip", ModRoot + ".*");
            var f = Path.Combine("_zip", Tools.ToWinPath(ModRoot));
            foreach (var file in Directory.GetFiles(f, "*", SearchOption.AllDirectories))
            {

                var newPath = Path.Combine(OutputDir,file.Substring(f.Length+1));
                if (!Directory.Exists(Path.GetDirectoryName(newPath))) Directory.CreateDirectory(Path.GetDirectoryName(newPath));
                File.Move(file, newPath);
            }
            if(Directory.Exists("_zip")) Directory.Delete("_zip", true);
        }
Exemple #29
0
 /// <summary>
 /// Unzips a file
 /// </summary>
 /// <param name="ZipFile">The Zip file to unpack</param>
 /// <param name="Directory">The directory to unpack to</param>
 /// <param name="FileFilter">#ZipLib-Style FileFilter</param>
 /// <param name="ErrorActions">The ErrorActions to pass to the logger</param>
 /// <param name="ignoreError">Whether to showError on failure</param>
 /// <param name="silent">Whether to show basic messages</param>
 public static bool unZip(string ZipFile, string Directory, string FileFilter = "", string[] ErrorActions = null, bool silent = false, bool ignoreError = false)
 {
     if (!silent) Logging.logMessage("Unzipping: " + ZipFile);
     FastZip fz = new FastZip();
     try
     {
         fz.ExtractZip(ZipFile, Directory, FileFilter);
     }
     catch (Exception e)
     {
         if (!ignoreError) Logging.showError(e.ToString(), ErrorActions);
         return false;
     }
     fz = null;
     return true;
 }
 /// <summary>
 /// Handles.
 /// </summary>
 /// <param name="context">Context</param>
 internal override void Handle( UpdateContext context )
 {
     FastZip zipper = new FastZip();
     string fileName = UpdateContext.LocalPackageFileName;
     try
     {
         zipper.ExtractZip(fileName,
     	                  Path.GetDirectoryName(fileName),
                           String.Empty);
         _extracted = true;
     }
     catch (SharpZipBaseException ex) 
     {
     	LoggingService.Fatal(ex);
     	_extracted = false;
     }
 }
Exemple #31
0
        static void ExtractZip(string filename, string Name, string basepath)
        {

            string dewLoc = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "ElDewrito");
            string fileloc = System.IO.Path.Combine(Directory.GetCurrentDirectory(), filename);

            FastZip fastZip = new FastZip();
            string filter = null;

            Stopwatch watcher = Stopwatch.StartNew();

            Console.WriteLine("Extraction started for: " + Name);
            watcher.Restart();
            fastZip.ExtractZip(filename, dewLoc, filter);
            watcher.Stop();
            Console.WriteLine("Extraction finished for: " + Name + " in {0}.\n ", watcher.Elapsed);
        }
 private bool doUnzipFile()
 {
     try
     {
         FastZip fastZip = new FastZip();
         fastZip.ExtractZip(zipfile, Application.StartupPath, "");
         statusLabel.Text = "Update done!";
         this.Update();
         checksDone = true;
         return true;
     }
     catch
     {
         statusLabel.Text = "The archive seems to be corrupt!" + System.Environment.NewLine + "Please re-download.";
         checksDone = true;
         return false;
     }
 }
Exemple #33
0
		protected void SetUp()
		{
			Common.Testing = true;
			RegistryKey myKey = Registry.LocalMachine.OpenSubKey("Software\\Classes\\AutoIt3Script\\Shell\\Run\\Command", false);
			if (myKey != null)
			{
				_autoIt = myKey.GetValue("", "").ToString();
				if (_autoIt.EndsWith(@" ""%1"" %*"))
					_autoIt = _autoIt.Substring(0, _autoIt.Length - 8);
				else if (_autoIt.EndsWith(@" ""%1"""))
					_autoIt = _autoIt.Substring(0, _autoIt.Length - 5);     // Remove "%1" at end
			}
			_scriptPath = PathPart.Bin(Environment.CurrentDirectory, "/XhtmlExport");
			_tf = new TestFiles("XhtmlExport");
			var pwf = Common.PathCombine(Common.GetAllUserAppPath(), "SIL");
			var zf = new FastZip();
			zf.ExtractZip(_tf.Input("Pathway.zip"), pwf, ".*");
		}
Exemple #34
0
        /// <summary>
        /// 转换
        /// </summary>
        /// <param name="sourceFile"></param>
        /// <param name="dest"></param>
        /// <returns></returns>
        public override List <string> DoDecompress(string sourceFile, string dest)
        {
            var result = Decompress(sourceFile, DestDirectory);

            return(result);

            if (false)
            {
                System.IO.Compression.ZipFile.ExtractToDirectory(sourceFile, DestDirectory);
            }

            if (false)
            {
                ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();
                if (!String.IsNullOrEmpty(Password))
                {
                    fastZip.Password = Password;
                }
                fastZip.ExtractZip(sourceFile, DestDirectory, "");
            }
        }