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


C# ZipFile.Dispose方法代码示例

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


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

示例1: Main

            static void Main(string[] args) {
               
               string ZipFilePath = Path.Combine("", "TestArchive.zip");
               if (File.Exists(ZipFilePath)) File.Delete(ZipFilePath);
                var zip = new ZipFile(ZipFilePath);
                zip.AddDirectory("LocalVFS", "LocalVFS/");
                zip.Save();
                zip.Dispose();
                //
                ZipFileSystemConfiguration zc = ZipFileSystemConfiguration.CreateDefaultConfig(ZipFilePath,"_tmp_");
                ZipFileProvider lp = new ZipFileProvider(zc);
                bool exfd = lp.ExistFolder("LocalVFS/", true);
                if (exfd) {
                    lp.DeleteFolder("LocalVFS/");
                }
                byte[] dataTest = Encoding.UTF8.GetBytes("this is a test context!!!");
                File.WriteAllBytes("test.cs", dataTest);
                lp.CreateFolder("LocalVFS/");
                string filepath = lp.CreateFilePath("LocalVFS/", "test.txt");

                //lp.MoveFile("test.cs", filepath);
                byte[] dataTest2 = Encoding.UTF8.GetBytes("this is a test write data!!!");
                using (MemoryStream ms = new MemoryStream(dataTest2)) {
                    lp.WriteFile("LocalVFS/test.txt", ms, true, dataTest2.Length, ContentUtil.UnknownContentType);
                }
                //lp.DeleteFile("LocalVFS/test.txt");
                lp.CopyFolder("LocalVFS/", "localvfs_test/");
                lp.Dispose();
                int jj = 0;
            }
开发者ID:RainsSoft,项目名称:UJad-AI-VFS,代码行数:30,代码来源:_Test_ZipVFS_.cs

示例2: bgWorker_Finish

        private void bgWorker_Finish(object sender, RunWorkerCompletedEventArgs e)
        {
            dlElapsedTimer.Stop();
            try
            {
                if (File.Exists(zipTarget))
                {
                    using (ZipFile zip = new ZipFile(zipTarget))
                    {
                        zip.ExtractAll(Directory.GetCurrentDirectory(), ExtractExistingFileAction.OverwriteSilently);
                        zip.Dispose();
                    }

                    File.Delete(zipTarget);
                    Process start = new Process();
                    start.StartInfo.FileName = exeTarget;
                    start.StartInfo.Arguments = "ProcessStart.cs";
                    start.Start();
                    Application.Exit();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error with the updater. Check your connection and try running as an administrator.\r\n\r\n" + ex.Message);
                Application.Exit();
            }
        }
开发者ID:Frostbrood,项目名称:StealthClient,代码行数:27,代码来源:Updater.cs

示例3: InitFileSystem

    /// <summary>
    /// Returns a file system implementation, which is assigned
    /// to the <see cref="TestContext.FileSystem"/> property.
    /// </summary>
    /// <param name="localTestFolder">The temporary test folder that is
    /// used by the context. This is actually just the <see cref="TestContext.LocalTestRoot"/>
    /// reference.</param>
    protected override IFileSystemProvider InitFileSystem(DirectoryInfo localTestFolder)
    {
      //init empty zip file
      ZipFilePath = Path.Combine(localTestFolder.FullName, "TestArchive.zip");
      var zip = new ZipFile(ZipFilePath);
      zip.Save();
      zip.Dispose();

      //init transfer stores
      var downloadTransferStore = new TestTransferStore<ZipDownloadTransfer>();
      var uploadTransferStore = new TestTransferStore<ZipUploadTransfer>();

      //init configuration
      var tempFactory = new TempFileStreamFactory(LocalTestRoot.FullName);

      var zipFile = new FileInfo(ZipFilePath);

      var configuration = new ZipFileSystemConfiguration(zipFile, tempFactory);
      configuration.RootName = "Test Root";
      configuration.DownloadStore = downloadTransferStore;
      configuration.UploadStore = uploadTransferStore;
      configuration.DownloadTokenExpirationTime = TimeSpan.FromHours(24);
      configuration.UploadTokenExpirationTime = TimeSpan.FromHours(24);
      configuration.DefaultDownloadBlockSize = 32768;
      configuration.MaxDownloadBlockSize = 32768 * 2;
      configuration.MaxUploadBlockSize = 32768 * 4;
      configuration.MaxUploadFileSize = (long)1024 * 1024 * 2048; //2GB limit



      //create provider
      Provider = new ZipFileProvider(configuration);
      return Provider;
    }
开发者ID:RainsSoft,项目名称:UJad-AI-VFS,代码行数:41,代码来源:ZipTestSuiteContext.cs

示例4: GKWriteConfiguration

		public OperationResult<bool> GKWriteConfiguration(Guid clientUID, Guid deviceUID)
		{
			var device = GKManager.Devices.FirstOrDefault(x => x.UID == deviceUID);
			if (device != null)
			{
				var progressCallback = new GKProgressCallback();
				ServerTaskRunner.Add(progressCallback, "Запись конфигурации ГК", (() =>
				{
					if (GKManager.DeviceConfiguration.OnlyGKDeviceConfiguration)
					{
						var deviceConfigFileName = AppDataFolderHelper.GetServerAppDataPath("Config" + Path.DirectorySeparatorChar + "GKDeviceConfiguration.xml");
						var zipDeviceConfigFileName = AppDataFolderHelper.GetServerAppDataPath("GKDeviceConfiguration.fscp");
						if (File.Exists(zipDeviceConfigFileName))
							File.Delete(zipDeviceConfigFileName);
						var zipFile = new ZipFile(zipDeviceConfigFileName);
						zipFile.AddFile(deviceConfigFileName, "");
						zipFile.Save(zipDeviceConfigFileName);
						zipFile.Dispose();
					}
					var result = GKProcessorManager.GKWriteConfiguration(device, GetUserName(clientUID), progressCallback, clientUID);
					NotifyOperationResult_WriteConfiguration(result, clientUID);
				}
				));
				return new OperationResult<bool>(true);
			}
			return OperationResult<bool>.FromError("Не найдено устройство в конфигурации. Предварительно необходимо применить конфигурацию");
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:27,代码来源:RubezhService.GK.cs

示例5: CollectLogFiles

    private static void CollectLogFiles(string dataPath, string outputPath, List<string> products)
    {
      if (!Directory.Exists(outputPath))
        Directory.CreateDirectory(outputPath);

      string targetFile = string.Format("MediaPortal2-Logs-{0}.zip", DateTime.Now.ToString("yyyy-MM-dd-HH.mm.ss"));
      targetFile = Path.Combine(outputPath, targetFile);
      if (File.Exists(targetFile))
        File.Delete(targetFile);

      ZipFile archive = new ZipFile(targetFile);
      foreach (var product in products)
      {
        string sourceFolder = Path.Combine(dataPath, @"Team MediaPortal", product, "Log");
        if (!Directory.Exists(sourceFolder))
        {
          Console.WriteLine("Skipping non-existant folder {0}", sourceFolder);
          continue;
        }
        Console.WriteLine("Adding folder {0}", sourceFolder);
        try
        {
          archive.AddDirectory(sourceFolder, product);
        }
        catch (Exception ex)
        {
          Console.WriteLine("Error adding folder {0}: {1}", sourceFolder, ex);
        }
      }
      archive.Save();
      archive.Dispose();
      Console.WriteLine("Successful created log archive: {0}", targetFile);

      Process.Start(outputPath); // Opens output folder
    }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:35,代码来源:Program.cs

示例6: zipFolder

 public string zipFolder(string strPathOfFolderToZip, string strTargetZipFileName)
 {
     var zpZipFile = new ZipFile(strTargetZipFileName);
     zpZipFile.AddDirectory(strPathOfFolderToZip, "");
     //zpZipFile.TrimVolumeFromFullyQualifiedPaths = true;
     zpZipFile.Save();
     zpZipFile.Dispose();
     return strTargetZipFileName;
 }
开发者ID:pusp,项目名称:o2platform,代码行数:9,代码来源:zipUtils.cs

示例7: GivenIUnzipThatPackageIntoADeploymentFolder

 public void GivenIUnzipThatPackageIntoADeploymentFolder()
 {
     var folder = (string)ScenarioContext.Current["targetFolder"];
     if (Directory.Exists(folder)) 
         Directory.Delete(folder, true);
     var zip = new ZipFile((string)ScenarioContext.Current["targetZip"]);
     zip.ExtractAll(folder);
     zip.Dispose();
 }
开发者ID:AtwooTM,项目名称:opencover,代码行数:9,代码来源:PackagingSteps.cs

示例8: DownloadSupportFile

 private void DownloadSupportFile(string fileName)
 {
     string fileSourceUrl = "http://DeltaEngine.net/" + AndroidDriverFolderName + "/" + fileName;
     string targetFilePath = Path.Combine(AndroidDriverFolderName, fileName);
     new WebClient().DownloadFile(fileSourceUrl, targetFilePath);
     var driversFile = new ZipFile(targetFilePath);
     driversFile.ExtractAll(DownloadDirectory, ExtractExistingFileAction.OverwriteSilently);
     driversFile.Dispose();
     File.Delete(targetFilePath);
 }
开发者ID:remy22,项目名称:DeltaEngine,代码行数:10,代码来源:AndroidDriverDownloader.cs

示例9: CreatEmptyZipFile

 public bool CreatEmptyZipFile(string zipfilepath) {
     try {
         if (File.Exists(zipfilepath)) File.Delete(zipfilepath);
         ZipFile zip = new ZipFile(zipfilepath);
         zip.Save();
         zip.Dispose();
         return true;
     }
     catch { 
         
     }
     return false;
 }
开发者ID:RainsSoft,项目名称:UJad-AI-VFS,代码行数:13,代码来源:ZipFileProvider.cs

示例10: generarZip

 /// <summary>
 /// Función que se utiliza para comprimir una carpeta o un archivo
 /// </summary>
 /// <param name="path"> Ruta fisica del archivo o carpeta a comprimir </param>
 /// <param name="fileOrForlder"> Indica si lo que se desea comprimir es un Archivo o una carpeta </param>
 /// <returns> True si la operación se completo sin problemas </returns>
 /// <remarks>
 /// <list> Creado Agosto 14 de 2013 - Ing david pineda </list>
 /// </remarks>
 public static void generarZip(string path, bool fileOrForlder)
 {
     ZipFile zip = new ZipFile();
     try
     {
         if (fileOrForlder)
         {
             //Si es un Archivo
             using (zip)
             {
                 zip.AddFile(path);
                 string path_zip = path.Replace(Path.GetFileName(path), Path.Combine(Path.GetFileNameWithoutExtension(path), ".zip"));
                 if (System.IO.File.Exists(path_zip))
                 {
                     System.IO.File.Delete(path_zip);
                 }
                 zip.Save(path_zip);
             }
         }
         else
         {
             //Si es un Folder - Carpeta
             using (zip)
             {
                 zip.AddDirectory(path);
                 string path_zip = path + ".zip";
                 if (System.IO.File.Exists(path_zip))
                 {
                     System.IO.File.Delete(path_zip);
                 }
                 zip.Save(path_zip);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         //Se agrega la el Dispose para asegurar que se liberen recursos
         zip.Dispose();
     }
 }
开发者ID:DavidPineda,项目名称:RipsValidador,代码行数:53,代码来源:ManagedZip.cs

示例11: ZipConvertedAudioFiles

        public static string ZipConvertedAudioFiles(IEnumerable<string> convertedAudioFilenames)
        {
            var zippedFileName = string.Empty;

            try
            {
                zippedFileName = FileNameGenerationHelper.GenerateFilename();
                var zip = new ZipFile(Path.Combine(HttpContext.Current.Server.MapPath("~/App_Data"), zippedFileName));
                zip.AddFiles(convertedAudioFilenames.Select(caf => Path.Combine(HttpContext.Current.Server.MapPath("~/App_Data"), caf)), false, "");
                zip.Save();
                zip.Dispose();
            }
            catch (Exception e)
            {
                throw new ZipException(e.Message);
            }

            return zippedFileName;
        }
开发者ID:UIKit0,项目名称:TubeToTune,代码行数:19,代码来源:FileZippingHelper.cs

示例12: SaveToZipFile

		public static void SaveToZipFile(string fileName, XDeviceConfiguration deviceConfiguration)
		{
			var folderName = AppDataFolderHelper.GetTempFolder();
			if (!Directory.Exists(folderName))
				Directory.CreateDirectory(folderName);

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

			deviceConfiguration.BeforeSave();
			deviceConfiguration.Version = new ConfigurationVersion() { MinorVersion = 1, MajorVersion = 1 };
			ZipSerializeHelper.Serialize(deviceConfiguration, Path.Combine(folderName, "XDeviceConfiguration.xml"));
			var zipFile = new ZipFile(fileName);
			zipFile.AddDirectory(folderName);
			zipFile.Save(fileName);
			zipFile.Dispose();
			if (Directory.Exists(folderName))
				Directory.Delete(folderName, true);
		}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:19,代码来源:ZipFileConfigurationHelper.cs

示例13: LoadZipFile

        private void LoadZipFile(ZipFile ZipFileObject)
        {
            try
            {
                Response.ClearContent();
                Response.AppendHeader("Content-Disposition", "attachment; filename=Comprobantes.zip");
                Response.ContentType = "application/x-zip-compressed";

                ZipFileObject.Save(Response.OutputStream);

                Response.End();

                ZipFileObject.Dispose();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
                Response.End();
            }
        }
开发者ID:javierlov,项目名称:FE,代码行数:20,代码来源:DownloadMultiple.aspx.cs

示例14: zip_Files

		public static string zip_Files(this List<string> filesToZip, string targetZipFile)//, string baseFolder)
		{		
			"Creating ZipFile with {0} files to {1}".info(filesToZip.size(), targetZipFile);
			if (targetZipFile.fileExists())
				Files.deleteFile(targetZipFile);
            var zpZipFile = new ZipFile(targetZipFile);            
            foreach(var fileToZip in filesToZip)
            {            	
            	{
            		zpZipFile.AddFile(fileToZip);            
            	}
            	//catch(Exception ex)
            	{
            	//	"[zip_Files] {0} in file {1}".error(ex.Message, fileToZip);
            	}
            }
            zpZipFile.Save();
            zpZipFile.Dispose();
            return targetZipFile;        
		}
开发者ID:pusp,项目名称:o2platform,代码行数:20,代码来源:_Extra_methods_Zip.cs

示例15: RunAsync

        private async Task RunAsync(CancellationToken cancellationToken)
        {
            // TODO: Replace the following with your own logic.
            while (!cancellationToken.IsCancellationRequested)
            {
                /*
                 * To backup all files to folder backups every 60s. And save no more than 5 backup files. 
                 * If you want to change the blob container, you can change the "blobcontainer" to your blob container name.
                 */
                var blobStorage = new BlobStorage("blobcontainer");
                //Use local storage
                LocalResource myStorage = RoleEnvironment.GetLocalResource("Backup");
                string filePath = Path.Combine(myStorage.RootPath, "backup");
                Directory.CreateDirectory(filePath);

                //Download all files to local storage
                blobStorage.DownloadToLocalStorage(myStorage, "", filePath);
                //Zip the directory
                ZipFile zipFile = new ZipFile();
                string zipPath = filePath + ".zip";
                zipFile.AddDirectory(filePath);
                zipFile.Save(zipPath);
                zipFile.Dispose();
                //Put it back to archives folder of container
                string uploadPath = Path.Combine("backups", Path.GetFileNameWithoutExtension(zipPath) + "-" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".zip");
                blobStorage.PutBlob(uploadPath, zipPath);

                var blobs = blobStorage.Container.ListBlobs("backups/", false, BlobListingDetails.None);

                //No more than 5 backup files
                if(blobs.Count() > 5)
                {
                    var deleteBlob = blobs.OrderBy(b => b.Uri.ToString()).First();
                    var blob = blobStorage.Container.GetBlockBlobReference("backups/" + Path.GetFileName(deleteBlob.Uri.ToString()));
                    blob.Delete();
                }

                Trace.TraceInformation("Working");
                await Task.Delay(60000);
            }
        }
开发者ID:RogerDong,项目名称:3NET-Project,代码行数:41,代码来源:WorkerRole.cs


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