当前位置: 首页>>代码示例>>C#>>正文


C# Zip.FastZip类代码示例

本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.FastZip的典型用法代码示例。如果您正苦于以下问题:C# FastZip类的具体用法?C# FastZip怎么用?C# FastZip使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FastZip类属于ICSharpCode.SharpZipLib.Zip命名空间,在下文中一共展示了FastZip类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExtractArchive

        internal static bool ExtractArchive(string archive, string destination)
        {

            //REFACTOR: Only create RAR and ZIP classes after discovering that the file actually has a .zip or .rar extension
            FileInfo archiveFI = new FileInfo(archive);
            Rar rar = new Rar();
            FastZip fz = new FastZip();

            double archivesize = archiveFI.Length * 2;
            char driveLetter = archiveFI.FullName[0];


            if (!CheckDiskSpaceQuota(archivesize, driveLetter)) return false;


            if (archiveFI.Extension == ".rar" || archiveFI.Extension == ".RAR")
                return ExtractRarArchive(archive, destination, archiveFI, rar);

            // ReSharper disable ConvertIfStatementToReturnStatement
            if (archiveFI.Extension == ".zip" || archiveFI.Extension == ".ZIP")
            // ReSharper restore ConvertIfStatementToReturnStatement
                return ExtractZipArchive(archive, destination, fz);

            //TODO: Should this return false?
            return true;

        }
开发者ID:stavrossk,项目名称:MeediFier_for_MeediOS,代码行数:27,代码来源:ArchiveExtractor.cs

示例2: ExtractZipArchive

        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;
        }
开发者ID:stavrossk,项目名称:MeediFier_for_MeediOS,代码行数:33,代码来源:ArchiveExtractor.cs

示例3: UnzipNewAgentVersion

 private void UnzipNewAgentVersion()
 {
     _logger.Log("Unzipping files");
     var fz = new FastZip();
     fz.ExtractZip(Constants.AgentServiceReleasePackage, Constants.AgentServiceUnzipPath, "");
     _logger.Log("Unzipping files complete");
 }
开发者ID:rackerlabs,项目名称:openstack-guest-agents-windows-xenserver-old,代码行数:7,代码来源:InstallAgentService.cs

示例4: Program

        public Program()
        {
            string[] dirs=Directory.GetDirectories(".");
            foreach (string dir in dirs)
            {

                DataBase.AnimatedBitmap an = new DataBase.AnimatedBitmap();
                an._Name =Path.GetFileName(dir);
                foreach (string file in Directory.GetFiles(dir))
                    if (Regex.IsMatch(Path.GetExtension(file), "jpg|png", RegexOptions.IgnoreCase))
                        an._Bitmaps.Add(file.Replace(@"\", "/","./",""));

                if (an._Bitmaps.Count > 0)
                {
                    Image img = Bitmap.FromFile(an._Bitmaps.First());
                    an._Width = img.Width;
                    an._Height = img.Height;
                    _DataBase._AnimatedBitmaps.Add(an);

                }
            }
            Common._XmlSerializer.Serialize("./db.xml", _DataBase);

            FastZip _FastZip = new FastZip();
            _FastZip.CreateZip("content.zip","./",true,@"\.jpg|\.png|.\xml");
        }
开发者ID:vonhacker,项目名称:counterstrike,代码行数:26,代码来源:Program.cs

示例5: DownloadAndUpdateSnakeBite

        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);
        }
开发者ID:topher-au,项目名称:SnakeBite,代码行数:30,代码来源:Program.cs

示例6: MergeFile

 private static async Task MergeFile( MergeParams p ) {
     var zf = new FastZip();
     using ( var s = File.OpenWrite( p.DestImg ) ) {
         s.Seek( 0, SeekOrigin.End );
         zf.CreateZip( s, Path.GetDirectoryName( p.DataSource ), false, Path.GetFileName( p.DataSource ), "" );
     }
 }
开发者ID:EpicMorg,项目名称:EMRJT,代码行数:7,代码来源:Merger.cs

示例7: UnzipProject

        /// <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;
        }
开发者ID:ecell,项目名称:ecell3-ide,代码行数:34,代码来源:ZipUtil.cs

示例8: BackupNow

        public static void BackupNow(MCServer s)
        {
            Database.AddLog("Backing up " + s.ServerTitle, "backup");

            //Check for a backup dir and create if not
            if (!Directory.Exists(s.ServerDirectory + @"\backups\")) Directory.CreateDirectory(s.ServerDirectory + @"\backups\");

            //Force a save
            s.Save();
            s.DisableSaving();

            //Copy world to a temp Dir
            if (Directory.Exists(Core.StoragePath + s.ServerID.ToString() + @"\backups\temp\")) Directory.Delete(Core.StoragePath + s.ServerID.ToString() + @"\backups\temp\", true);
            if (!Directory.Exists(Core.StoragePath + s.ServerID.ToString() + @"\backups\temp\")) Directory.CreateDirectory(Core.StoragePath + s.ServerID.ToString() + @"\backups\temp\");
            Util.Copy(s.ServerDirectory + @"\world\", s.ServerDirectory + @"\backups\temp\");

            //Re-enable saving then force another save
            s.EnableSaving();
            s.Save();

            //Now zip up temp dir and move to backups
            FastZip z = new FastZip();
            z.CreateEmptyDirectories = true;
            z.CreateZip(s.ServerDirectory + @"\backups\" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Hour + "-" + DateTime.Now.Minute + ".zip", s.ServerDirectory + @"\backups\temp\", true, "");

            //If the server is empty, reset the HasChanged
            if (s.Players.Count == 0) s.HasChanged = false;
        }
开发者ID:Rawwar13,项目名称:YAMS,代码行数:28,代码来源:Backup.cs

示例9: gerarZipDiretorio

 public void gerarZipDiretorio(string sDiretorioOrigem, string sDiretorioDestino)
 {
     FastZip sz = new FastZip();
     try
     {
         string sArquivoZip = string.Empty;
         //Aqui vou criar um nome do arquivo.
         DateTime newDate = DateTime.Now;
         sArquivoZip = "MeuZip_" + Convert.ToString(newDate).Replace("/", "_").Replace(":", "") + ".zip";
         //Só um tratamento para garantir mais estabilidade
         if (sDiretorioOrigem.Substring(sDiretorioOrigem.Length - 2) != "\\" || sDiretorioDestino.Substring(sDiretorioDestino.Length - 2) != "\\")
         {
             sDiretorioOrigem = sDiretorioOrigem + "\\";
         }
         sz.Password = txtDiretorioZipSenha.Text;
         //Gera o ZIP
         sz.CreateZip(sDiretorioDestino + sArquivoZip, sDiretorioOrigem + "" + "\\", true, "", "");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ocorreu um erro durante o processo de compactação : " + ex);
     }
     finally
     {
         //Limpa o Objeto
         sz = null;
     }
 }
开发者ID:danygolden,项目名称:gianfratti,代码行数:28,代码来源:Form1.cs

示例10: UnZipFile

 /// <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();
 }
开发者ID:hiramtan,项目名称:HiZip_unity,代码行数:30,代码来源:MyZip.cs

示例11: buttonCreateBackup_Click

        private void buttonCreateBackup_Click(object sender, EventArgs e)
        {
            if (Directory.Exists("_backup")) Directory.Delete("_backup", true);
            Directory.CreateDirectory("_backup");

            // prompt user for backup filename
            SaveFileDialog saveBackup = new SaveFileDialog();
            saveBackup.Filter = "SnakeBite Backup|*.sbb";
            DialogResult saveResult = saveBackup.ShowDialog();
            if (saveResult != DialogResult.OK) return;

            // copy current settings
            objSettings.SaveSettings();
            File.Copy(ModManager.GameDir + "\\sbmods.xml", "_backup\\sbmods.xml");

            // copy current 01.dat
            File.Copy(ModManager.GameArchivePath, "_backup\\01.dat");

            // compress to backup
            FastZip zipper = new FastZip();
            zipper.CreateZip(saveBackup.FileName, "_backup", true, "(.*?)");

            Directory.Delete("_backup", true);

            MessageBox.Show("Backup complete.", "SnakeBite", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
开发者ID:MrRSPEED9845,项目名称:SnakeBite,代码行数:26,代码来源:formMain.cs

示例12: PackFiles

    /// <summary>压缩文件</summary>
    /// <param name="filename">filename生成的文件的名称,如:C:\RAR\075_20110820153200001-1.rar</param>
    /// <param name="directory">directory要压缩的文件夹路径,如:C:\OA</param>
    /// <returns></returns>
    public static bool PackFiles(string filename, string directory)
    {
        try
        {

            directory = directory.Replace("/", "\\");

            if (!directory.EndsWith("\\"))
                directory += "\\";
            if (!System.IO.Directory.Exists(directory))
            {
                System.IO.Directory.CreateDirectory(directory);
            }
            if (System.IO.File.Exists(filename))
            {
                System.IO.File.Delete(filename);
            }
            FastZip fz = new FastZip();
            fz.CreateEmptyDirectories = true;
            fz.CreateZip(filename, directory, true, "");
            return true;
        }
        catch (Exception)
        {
            return false;
        }
    }
开发者ID:wjszxli,项目名称:hyoav10_gdcrm,代码行数:31,代码来源:list_bak.aspx.cs

示例13: Basics

        public void Basics()
        {
            const string tempName1 = "a(1).dat";

            MemoryStream target = new MemoryStream();

            string tempFilePath = GetTempFilePath();
            Assert.IsNotNull(tempFilePath, "No permission to execute this test?");

            string addFile = Path.Combine(tempFilePath, tempName1);
            MakeTempFile(addFile, 1);

            try {
                FastZip fastZip = new FastZip();
                fastZip.CreateZip(target, tempFilePath, false, @"a\(1\)\.dat", null);

                MemoryStream archive = new MemoryStream(target.ToArray());
                using (ZipFile zf = new ZipFile(archive)) {
                    Assert.AreEqual(1, zf.Count);
                    ZipEntry entry = zf[0];
                    Assert.AreEqual(tempName1, entry.Name);
                    Assert.AreEqual(1, entry.Size);
                    Assert.IsTrue(zf.TestArchive(true));

                    zf.Close();
                }
            }
            finally {
                File.Delete(tempName1);
            }
        }
开发者ID:firestrand,项目名称:SharpZipLib,代码行数:31,代码来源:ZipTests.cs

示例14: Main

        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");
        }
开发者ID:ChadSki,项目名称:MetroIdeTemplate,代码行数:60,代码来源:Program.cs

示例15: ChoosePackageDialog

        private void ChoosePackageDialog()
        {
            // Configure open file dialog box 
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName = "Document"; // Default file name 
            dlg.DefaultExt = ".AGT"; // Default file extension 
            dlg.Filter = "Agent Package (.agt)|*.agt"; // Filter files by extension 

            // Show open file dialog box 
            Nullable<bool> result = dlg.ShowDialog();

            // Process open file dialog box results 
            if (result == true)
            {
                // Open document 
                PackageSource = dlg.FileName;

                ICSharpCode.SharpZipLib.Zip.FastZip fz = new FastZip();

                var root = System.IO.Path.Combine(System.IO.Path.GetTempPath(), (Guid.NewGuid().ToString()));

                fz.ExtractZip(PackageSource, root, FastZip.Overwrite.Always, null, null, null, true);

                PackageFile = System.IO.Path.Combine(root, "package.json");

                if (System.IO.File.Exists(PackageFile))
                {
                    var cnt =  System.IO.File.ReadAllText(PackageFile);
                    Contents = cnt;
                }
            }
        }
开发者ID:nothingmn,项目名称:AGENT.Contrib,代码行数:32,代码来源:PackageViewerViewModel.cs


注:本文中的ICSharpCode.SharpZipLib.Zip.FastZip类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。