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


C# ZipFile.Save方法代码示例

本文整理汇总了C#中Ionic.Zip.ZipFile.Save方法的典型用法代码示例。如果您正苦于以下问题:C# ZipFile.Save方法的具体用法?C# ZipFile.Save怎么用?C# ZipFile.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ionic.Zip.ZipFile的用法示例。


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

示例1: CreateArchiveWithFiles

		public string CreateArchiveWithFiles(IEnumerable<Guid> files, string serverDirectoryPath, string userName, string archiveName)
		{
			string path = string.Format("{0}{1}\\{2}\\", serverDirectoryPath, _temp, userName);
			if (Directory.Exists(path))
			{
				Directory.Delete(path, true);
			}
			Directory.CreateDirectory(path);
			var fullPath = string.Format("{0}{1}", path, archiveName);

			using (var archive = new ZipFile(fullPath))
			{
				foreach (var file in files)
				{
					var document = _documentService.GetDocumentInfo(file);
					var documentBytes = _documentService.GetDocument(file);
					archive.AddEntry(document.Name, documentBytes);
					archive.Save();
				}

				archive.Save();
			}

			return fullPath;
		}
开发者ID:evkap,项目名称:DVS,代码行数:25,代码来源:ArchiveService.cs

示例2: Main

        static void Main(string[] args)
        {
            const string releaseDir = @"";
            var assemblyPath = Path.Combine(Path.Combine(Environment.CurrentDirectory, releaseDir), "LINQPadLog4jDriver.dll");
            var assembly = Assembly.LoadFile(assemblyPath);
            var version = assembly.GetName().Version;

            using (var ms = new MemoryStream())
            using (var releaseZip = new ZipFile())
            using (var lpx45 = new ZipFile())
            {
                var releaseZipPath = Path.Combine(releaseDir, string.Format("Log4jLinqpadDriver {0}.zip", version));
                lpx45.AddFile(Path.Combine(Environment.CurrentDirectory, "LINQPadLog4jDriver.dll"), "");
                lpx45.AddFile(Path.Combine(Environment.CurrentDirectory, "header.xml"), "");
                lpx45.Save(ms);
                ms.Seek(0, SeekOrigin.Begin);
                releaseZip.AddEntry("Log4jLinqpadDriver.lpx", ms);

                releaseZip.Save(releaseZipPath);
                ms.SetLength(0);

                // readme
                releaseZip.AddFile(Path.Combine(releaseDir, "readme.txt"), "");
                releaseZip.Save(releaseZipPath);
            }

            // open
            Process.Start(Environment.CurrentDirectory);
        }
开发者ID:BerserkerDotNet,项目名称:LINQPadLog4jDriver,代码行数:29,代码来源:Program.cs

示例3: Main

        static void Main(string[] args)
        {
            var a = new Arguments(args);
            using (var z = new ZipFile())
            {
                Console.WriteLine("Compiling... ");

                switch (a["target"])
                {
                    case "plugin":
                        compilePlugin(a, z);

                        z.Save(new DirectoryInfo(a["path"]).Parent.FullName + "\\" + a["output"]);

                        break;
                    case "library":
                        compileLibrary(a, z);

                        z.Save(a["sources"] + "\\" + a["output"]);

                        break;
                }

            }

            Console.WriteLine("Done");
        }
开发者ID:SchwarzerLoewe,项目名称:OpenIDE,代码行数:27,代码来源:Program.cs

示例4: CreatePackage

        public bool CreatePackage(string filename, bool includeWalkthrough, out string error, IEnumerable<WorldModel.PackageIncludeFile> includeFiles, Stream outputStream)
        {
            error = string.Empty;

            try
            {
                string data = m_worldModel.Save(SaveMode.Package, includeWalkthrough);
                string baseFolder = Path.GetDirectoryName(m_worldModel.Filename);

                using (ZipFile zip = new ZipFile())
                {
                    zip.AddEntry("game.aslx", data, Encoding.UTF8);

                    if (includeFiles == null)
                    {
                        var fileTypesToInclude = m_worldModel.Game.Fields[FieldDefinitions.PublishFileExtensions] ??
                                             "*.jpg;*.jpeg;*.png;*.gif;*.js;*.wav;*.mp3;*.htm;*.html;*.svg";

                        foreach (var file in m_worldModel.GetAvailableExternalFiles(fileTypesToInclude))
                        {
                            zip.AddFile(Path.Combine(baseFolder, file), "");
                        }
                    }
                    else
                    {
                        foreach (var file in includeFiles)
                        {
                            zip.AddEntry(file.Filename, file.Content);
                        }
                    }

                    AddLibraryResources(zip, baseFolder, ElementType.Javascript);
                    AddLibraryResources(zip, baseFolder, ElementType.Resource);

                    if (filename != null)
                    {
                        zip.Save(filename);
                    }
                    else if (outputStream != null)
                    {
                        zip.Save(outputStream);
                    }
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return false;
            }

            return true;
        }
开发者ID:hyrmedia,项目名称:quest,代码行数:52,代码来源:Packager.cs

示例5: Zip

    public static void Zip(string zipFileName, params string[] files)
    {
        #if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
        string path = Path.GetDirectoryName(zipFileName);
        Directory.CreateDirectory(path);

        using (ZipFile zip = new ZipFile())
        {
            foreach (string file in files)
            {
                zip.AddFile(file, "");
            }
            zip.Save(zipFileName);
        }
        #elif UNITY_ANDROID
        using (AndroidJavaClass zipper = new AndroidJavaClass ("com.tsw.zipper")) {
            {
                zipper.CallStatic ("zip", zipFileName, files);
            }
        }
        #elif UNITY_IPHONE
        foreach (string file in files) {
            addZipFile (file);
        }
        zip (zipFileName);
        #endif
    }
开发者ID:hybrid1969,项目名称:Polimi-OSM-City-Engine,代码行数:27,代码来源:UniZip.cs

示例6: button3_Click

 private void button3_Click(object sender, RoutedEventArgs e)
 {
     Directory.SetCurrentDirectory("C:/tmp/soundpcker");
     using (ZipFile zip = new ZipFile())
     {
         // add this map file into the "images" directory in the zip archive
         zip.AddFile("pack.mcmeta");
         // add the report into a different directory in the archive
         zip.AddItem("assets");
         zip.AddFile("lcrm");
         zip.Save("CustomSoundInjector_ResourcePack.zip");
     }
         SaveFileDialog saveFileDialog = new SaveFileDialog();
     saveFileDialog.DefaultExt = ".zip";
     saveFileDialog.Filter = "Minecraft ResourcePack (with Bytecode)|*.zip";
     if (saveFileDialog.ShowDialog() == true)
     {
         exportpath = saveFileDialog.FileName;
     }
     else
     {
         MessageBox.Show("Operation Cancelled.", "Cancelled", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     string originExport = "C:/tmp/soundpcker/CustomSoundInjector_ResourcePack.zip";
     File.Copy(originExport, exportpath, true);
     MessageBox.Show("Saved.", "Saved", MessageBoxButton.OK, MessageBoxImage.Information);
 }
开发者ID:GabrielTK,项目名称:MinecraftSoundChanger,代码行数:27,代码来源:EditMusicDisk.xaml.cs

示例7: extractIPA

 public static String extractIPA(IPAInfo info)
 {
     using (ZipFile ipa = ZipFile.Read(info.Location))
     {
         Debug("IPALocation: " + info.Location);
         Debug("Payload location: " + info.BinaryLocation);
         foreach (ZipEntry e in ipa)
         {
             //Debug ("file:" + e.FileName);
             if (e.FileName.Contains(".sinf") || e.FileName.Contains(".supp"))
             {
                 //extract it
                 Debug(GetTemporaryDirectory());
                 e.Extract(GetTemporaryDirectory(), ExtractExistingFileAction.OverwriteSilently);
             }
             else if (e.FileName == info.BinaryLocation)
             {
                 Debug("found binary!!");
                 e.Extract(GetTemporaryDirectory(), ExtractExistingFileAction.OverwriteSilently);
             }
         }
     }
     //zip!
     String AppDirectory = Path.Combine(GetTemporaryDirectory(), "Payload");
     Debug("AppDirectory: " + AppDirectory);
     //return null;
     String ZipPath = Path.Combine(GetTemporaryDirectory(), "upload.ipa");
     using (ZipFile zip = new ZipFile())
     {
         zip.CompressionLevel = Ionic.Zlib.CompressionLevel.None;
         zip.AddDirectory(AppDirectory);
         zip.Save(ZipPath);
     }
     return ZipPath;
 }
开发者ID:koufengwei,项目名称:Brake,代码行数:35,代码来源:AppHelper.cs

示例8: CreatePackage

        public bool CreatePackage(string filename, bool includeWalkthrough, out string error)
        {
            error = string.Empty;

            try
            {
                string data = m_worldModel.Save(SaveMode.Package, includeWalkthrough);
                string baseFolder = System.IO.Path.GetDirectoryName(m_worldModel.Filename);

                using (ZipFile zip = new ZipFile(filename))
                {
                    zip.AddEntry("game.aslx", data, Encoding.UTF8);
                    foreach (string file in m_worldModel.GetAvailableExternalFiles("*.jpg;*.jpeg;*.png;*.gif;*.js;*.wav;*.mp3;*.htm;*.html"))
                    {
                        zip.AddFile(System.IO.Path.Combine(baseFolder, file), "");
                    }
                    AddLibraryResources(zip, baseFolder, ElementType.Javascript);
                    AddLibraryResources(zip, baseFolder, ElementType.Resource);
                    zip.Save();
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return false;
            }

            return true;
        }
开发者ID:JatinR,项目名称:quest,代码行数:29,代码来源:Packager.cs

示例9: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();
        dt = cm.getdt("SELECT * FROM VW_RFI_ATCH_DTL_ALL_ZIP WHERE RAD_RFH_ID = 97");
        string output = "<style> table { min-width:600px; padding: 0px; box-shadow: 2px 2px 3px #888888; border: 1px solid #cccccc; -moz-border-radius-bottomleft: 0px; -webkit-border-bottom-left-radius: 0px; border-bottom-left-radius: 0px; -moz-border-radius-bottomright: 0px; -webkit-border-bottom-right-radius: 0px; border-bottom-right-radius: 0px; -moz-border-radius-topright: 0px; -webkit-border-top-right-radius: 0px; border-top-right-radius: 0px; -moz-border-radius-topleft: 0px; -webkit-border-top-left-radius: 0px; border-top-left-radius: 0px; } table table { height: 100%; margin: 0px; padding: 0px; } table tr:last-child td:last-child { -moz-border-radius-bottomright: 0px; -webkit-border-bottom-right-radius: 0px; border-bottom-right-radius: 0px; } table table tr:first-child td:first-child { -moz-border-radius-topleft: 0px; -webkit-border-top-left-radius: 0px; border-top-left-radius: 0px; } table table tr:first-child td:last-child { -moz-border-radius-topright: 0px; -webkit-border-top-right-radius: 0px; border-top-right-radius: 0px; } table tr:last-child td:first-child { -moz-border-radius-bottomleft: 0px; -webkit-border-bottom-left-radius: 0px; border-bottom-left-radius: 0px; } table tr:hover td { background-color: #e5e5e5; } table td { vertical-align: middle; background: -o-linear-gradient(bottom, #ffffff 5%, #e5e5e5 100%); background: -webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ffffff), color-stop(1, #e5e5e5) ); background: -moz-linear-gradient( center top, #ffffff 5%, #e5e5e5 100% ); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#e5e5e5'); background: -o-linear-gradient(top,#ffffff,e5e5e5); background-color: #ffffff; border: 1px solid #cccccc; border-width: 0px 1px 1px 0px; text-align: left; padding: 7px 4px 7px 4px; font-size: 10px; font-family: Arial; font-weight: normal; color: #000000; } table tr:last-child td { border-width: 0px 1px 0px 0px; } table tr td:last-child { border-width: 0px 0px 1px 0px; } table tr:last-child td:last-child { border-width: 0px 0px 0px 0px; } table tr:first-child td { background: -o-linear-gradient(bottom, #cccccc 5%, #b2b2b2 100%); background: -webkit-gradient( linear, left top, left bottom, color-stop(0.05, #cccccc), color-stop(1, #b2b2b2) ); background: -moz-linear-gradient( center top, #cccccc 5%, #b2b2b2 100% ); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#b2b2b2'); background: -o-linear-gradient(top,#cccccc,b2b2b2); background-color: #cccccc; border: 0px solid #cccccc; text-align: center; border-width: 0px 0px 1px 1px; font-size: 12px; font-family: Arial; font-weight: bold; color: #000000; } table tr:first-child:hover td { background: -o-linear-gradient(bottom, #cccccc 5%, #b2b2b2 100%); background: -webkit-gradient( linear, left top, left bottom, color-stop(0.05, #cccccc), color-stop(1, #b2b2b2) ); background: -moz-linear-gradient( center top, #cccccc 5%, #b2b2b2 100% ); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#b2b2b2'); background: -o-linear-gradient(top,#cccccc,b2b2b2); background-color: #cccccc; } table tr:first-child td:first-child { border-width: 0px 0px 1px 0px; } table tr:first-child td:last-child { border-width: 0px 0px 1px 1px; } table th { background: -o-linear-gradient(bottom, #ffffff 5%, #e5e5e5 100%); background: -webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ffffff), color-stop(1, #e5e5e5) ); background: -moz-linear-gradient( center top, #ffffff 5%, #e5e5e5 100% ); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#e5e5e5'); background: -o-linear-gradient(top,#ffffff,e5e5e5); background-color: #ffffff; border: 1px solid #888888; padding: 3px; font-family: Arial; font-size: 12px; } body { font-family: Arial; font-size: 12px; } </style>";
        output += "<div style=''><b>RFI for " + dt.Rows[0]["RAD_RFH_RFINO"].ToString() + "</b></div>";

        using (ZipFile zip = new ZipFile())
        {
            zip.AlternateEncodingUsage = ZipOption.Never;
            output += "<table>";
            output += "<tr><th>RFI Attach Type</th><th>Insepection</th><th>Remark</th><th>Date</th></tr>";
            foreach (DataRow row in dt.Rows)
            {
                output += "<tr>";
                if (File.Exists(Server.MapPath(row["RAD_FILE_SRVR"].ToString())))
                {
                    zip.AddFile(Server.MapPath(row["RAD_FILE_SRVR"].ToString()), (row["file_path"].ToString()));
                    output += "<td>";
                    output += (row["RAD_FILE_SRVR_link"].ToString());
                    output += "</td>";
                    output += "<td>";
                    output += (row["RAD_VAL_TYPE"].ToString());
                    output += "</td>";
                    output += "<td>";
                    output += (row["RAD_REMARKS"].ToString());
                    output += "</td>";
                    output += "<td>";
                    output += (row["RAD_DOC_DT"].ToString());
                    output += "</td>";
                }
                else
                {
                    output += "<td>";
                    output += "No file found";
                    output += "</td>";
                    output += "<td>";
                    output += (row["RAD_VAL_TYPE"].ToString());
                    output += "</td>";
                    output += "<td>";
                    output += (row["RAD_REMARKS"].ToString());
                    output += "</td>";
                    output += "<td>";
                    output += (row["RAD_DOC_DT"].ToString());
                    output += "</td>";
                    //zip.AddFile("");
                }
                output += "</tr>";
            }
            output += "</table>";
            byte[] data = Encoding.UTF8.GetBytes(output);
            zip.AddEntry("info.html", data);
            Response.Clear();
            Response.BufferOutput = false;
            Response.ContentType = "application/zip";
            Response.AddHeader("content-disposition", "attachment; filename=Zip_" + DateTime.Now.ToString("yyyy-MMM-dd-HHmmss") + ".zip");
            zip.Save(Response.OutputStream);
            Response.End();
        }
    }
开发者ID:niisar,项目名称:ASP.NET,代码行数:60,代码来源:DownloadZip1.aspx.cs

示例10: CreateSolution

        public string CreateSolution(IBuildBootstrappedSolutions bootstrapper, SolutionConfiguration configuration)
        {
            configuration.InCodeSubscriptions = true;
            foreach (var endpointConfiguration in configuration.EndpointConfigurations)
            {
                endpointConfiguration.InCodeSubscriptions = configuration.InCodeSubscriptions;
            }

            var solutionData = bootstrapper.BootstrapSolution(configuration);

            var solutionDirectory = SavePath + Guid.NewGuid();

            var solutionFile = SaveSolution(solutionDirectory, solutionData);

            InstallNuGetPackages(solutionDirectory, solutionData, solutionFile, NuGetExe);

            //AddReferencesToNugetPackages(solutionDirectory);

            var zipFilePath = solutionFile.Replace(".sln", ".zip");

            using (var zip = new ZipFile())
            {
                zip.AddDirectory(solutionDirectory, "Solution");
                zip.Save(zipFilePath);
            }

            return zipFilePath;
        }
开发者ID:ParticularLabs,项目名称:NServiceBus.Launchpad,代码行数:28,代码来源:SolutionSaver.cs

示例11: FolderToZip

 public void FolderToZip(string sourceDir, string path)
 {
     using (var surveyBackup = new ZipFile()) {
         surveyBackup.AddDirectory(sourceDir);
         surveyBackup.Save(path);
     }
 }
开发者ID:wurdum,项目名称:deployer,代码行数:7,代码来源:PackageManager.cs

示例12: ImportActionShouldAddTestsToProblemIfZipFileIsCorrect

        public void ImportActionShouldAddTestsToProblemIfZipFileIsCorrect()
        {
            var zipFile = new ZipFile();

            var inputTest = "input";
            var outputTest = "output";

            zipFile.AddEntry("test.001.in.txt", inputTest);
            zipFile.AddEntry("test.001.out.txt", outputTest);

            var zipStream = new MemoryStream();
            zipFile.Save(zipStream);
            zipStream = new MemoryStream(zipStream.ToArray());

            this.File.Setup(x => x.ContentLength).Returns(1);
            this.File.Setup(x => x.FileName).Returns("file.zip");
            this.File.Setup(x => x.InputStream).Returns(zipStream);

            var redirectResult = this.TestsController.Import("1", this.File.Object, false, false) as RedirectToRouteResult;
            Assert.IsNotNull(redirectResult);

            Assert.AreEqual("Problem", redirectResult.RouteValues["action"]);
            Assert.AreEqual(1, redirectResult.RouteValues["id"]);

            var tests = this.Data.Problems.All().First(pr => pr.Id == 1).Tests.Count;
            Assert.AreEqual(14, tests);

            var tempDataHasKey = this.TestsController.TempData.ContainsKey(GlobalConstants.InfoMessage);
            Assert.IsTrue(tempDataHasKey);

            var tempDataMessage = this.TestsController.TempData[GlobalConstants.InfoMessage];
            Assert.AreEqual("Тестовете са добавени към задачата", tempDataMessage);
        }
开发者ID:yuanlukito-ti,项目名称:OpenJudgeSystem,代码行数:33,代码来源:ImportActionTests.cs

示例13: Compress

 /// <summary>
 /// 压缩文件
 /// </summary>
 /// <param name="toDirectory">压缩到该目录</param>
 /// <param name="toFileName">压缩文件名,不带扩展名,自动添加.zip扩展名</param>
 public void Compress( string toDirectory, string toFileName ) {
     using ( var zip = new ZipFile() ) {
         zip.Password = _password;
         AddFiles( zip );
         zip.Save( GetFilePath( toDirectory, toFileName ) );
     }
 }
开发者ID:NetUtil,项目名称:Util,代码行数:12,代码来源:DotNetZip.cs

示例14: GetArchivedFiles

		public byte[] GetArchivedFiles(IEnumerable<Guid> files)
		{
			using (var ms = new MemoryStream())
			{
				using (var zip = new ZipFile())
				{
					foreach (var id in files)
					{
						var documentInfo = _documentService.GetDocumentInfo(id);
						var documentBytes = _documentService.GetDocument(id);

						if (documentInfo.IsEncrypted)
						{
							documentBytes = _cryptographicProvider.Decrypt(documentBytes).Value;
						}
						string dateString = documentInfo.DateAdded.ToString("MM.dd.yyyy_hh.mmtt", CultureInfo.InvariantCulture);
						string fileName = String.Format("{0}_{1}{2}", documentInfo.Name, dateString, documentInfo.DocumentType);
						zip.AddEntry(fileName, documentBytes);
					}

					zip.Save(ms);
					ms.Position = 0;

					return ms.ToArray();
				}
			}
		}
开发者ID:evkap,项目名称:DVS,代码行数:27,代码来源:ArchiveService.cs

示例15: Main

        static void Main(string[] args)
        {
            try
            {
                ZipDestinationPath = Path.Combine(Application.StartupPath, "..\\..\\..\\MovieFinder.Web\\App_Data\\MovieTube.zip");
                var configPath = Path.Combine(Application.StartupPath, "..\\..\\..\\MovieFinder.Web\\Web.config");
                Version version;
                if (!IsVersionChanged(out version))
                    return;

                if (File.Exists(ZipFileName))
                    File.Delete(ZipFileName);

                using (var zip = new ZipFile())
                {
                    foreach (var f in Files)
                        zip.AddFile(f, "");

                    zip.Save(ZipFileName);
                    File.Copy(ZipFileName, ZipDestinationPath, true);
                }

                var doc = XDocument.Load(configPath);
                var elem = doc.Root.Descendants("add").Where(x => (string)x.Attribute("key") == "AppVersion").Single().Attribute("value");
                elem.Value = version.ToString();
                doc.Save(configPath);
                MessageBox.Show("New version updated");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:huoxudong125,项目名称:VideoSearch,代码行数:33,代码来源:Program.cs


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