/*****Constructor*****/ /// <summary> /// Constructor, takes command line arguments where 0 is the zipfile. /// </summary> /// <param name="argIn">Command line arguments, where index 0 is the zipfile.</param> public IO_FilesIn(string argIn) : base(typeof(IO_FilesIn) , new object[] { argIn }) { if (!firstRun) { Files = ZipFiles.GetFiles(argIn).Where((x) => x != Log.logFileName).ToArray(); } }
static void Main(string[] args) { var folderName = args.Length > 0 ? args[0] : @"C:\dev\SampleZip\filesToZip"; var targetFile = args.Length > 0 ? args[1] : @"C:\dev\SampleZip\zippedFiles.zip"; ZipFiles.Go(folderName, targetFile); Console.WriteLine("Completed zipping"); Console.ReadLine(); }
private void 查看压缩包结构() { ZipFiles = Zip.GetZipFilesName(FilePath); if (!ZipFiles.Any(a => a.ToLower().Contains("data")) || ZipFiles.Any(a => a.ToLower().Contains("lol_game_client"))) { if (AyMessageBox.ShowCus(string.Format("皮肤包结构异常,可能为未整理过的美服皮肤包{0}是否使用自动整理功能?", Environment.NewLine), "皮肤包异常", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { 重新整理皮肤包(); } } }
private static void Main(string[] args) { try { // Get customer rules defined in preprocessor definitions. GetPreprocessorDefinitions(); SetTempDir(args[0]); string[] files = ZipFiles.GetFiles(args[0]); atrio = new AtrioPreProcess(files); atrio.SetDebug(args[0]); atrio = new AtrioPreProcess(files); // get files into temp directory CheckFiles(atrio.Files); // len check for implementation Statement/WelcomeLetters // input data to 691, 504A, 690 docs = PopulateDocs(atrio.Files); // TO DO: process them separately by filtering business rules // TO DO: process them together by key-based business rules atrio.ProcessDocs(docs); throw new Exception("Finish implementing ProcessDocs."); /**********************************/ // only remove debug if completes. Debug.Remove(); } catch (Exception err) { string Message = err.Message; string StackTrace = err.StackTrace; string SourceApplication = err.Source; Exception inner = err.InnerException; var DataDictionary = err.Data; Console.Write(String.Format("Error:\n\n{0}", err.ToString())); } finally { CleanUp(); } }
private void 解压压缩包的图片() { Comment = "解压压缩包的图片"; TempPath = Soft.ZipTempPath(Skin.Hero); FileOperations.CreateDir(TempPath); var files = ZipFiles.Where(d => d != null && (d.EndsWith(".dds") || d.EndsWith(".png") || d.EndsWith(".jpg") || d.EndsWith(".jpeg") || d.EndsWith(".bmp")) && !d.ToLower().Contains("particles")).ToList(); try { Zip.UnzipFiles(FilePath, TempPath, files); files = FileOperations.AllFiles(TempPath); 获取各种图片(files); } catch { AyMessageBox.Show("载入图读取失败!", "压缩包错误!"); } }
public static void CompressDirectoryTest( ) { string sourceDirectoryPath = Path.Combine(Directory.GetCurrentDirectory( ), @"DirectoryTest"); string targetDirectoryPath = Path.Combine(Path.GetTempPath( ), "DirectoryTest"); if (!Directory.Exists(sourceDirectoryPath)) { Assert.Fail(string.Format("Directory {0} does not exists", sourceDirectoryPath)); return; } Stream outStream = null; try { outStream = ZipFiles.Compress(sourceDirectoryPath); if (outStream == null) { Assert.Fail("Directory cannot be compressed."); return; } if (Directory.Exists(targetDirectoryPath)) { Directory.Delete(targetDirectoryPath, true); } ZipFiles.DecompressDirectory(targetDirectoryPath, outStream); } finally { if (outStream != null) { outStream.Close( ); } } Assert.AreEqual(Directory.Exists(targetDirectoryPath), true); Assert.AreEqual(File.Exists(Path.Combine(targetDirectoryPath, "FileTest1.txt")), true); Assert.AreEqual(File.Exists(Path.Combine(targetDirectoryPath, "FileTest2.txt")), true); Assert.AreEqual(Directory.Exists(Path.Combine(targetDirectoryPath, "DirectoryLevel2")), true); Assert.AreEqual(File.Exists(Path.Combine(targetDirectoryPath, "DirectoryLevel2", "FileTest3.txt")), true); }
private void UploadTaskFile(string machineTarget, TaskInfo task, string sharedPath) { if (string.IsNullOrEmpty(sharedPath)) { return; } FileUploadServiceClient fileServices = new FileUploadServiceClient(); var fileName = string.Format("{0}.{1}.{2}", machineTarget, task.Id.ToString(), ZipFiles.FILE_EXTENSION); var stream = ZipFiles.Compress(sharedPath); if (stream == null) { return; } fileServices.UploadFile(fileName, stream); }
public static void CompressFileTest( ) { string sourceFilePath = Path.Combine(Directory.GetCurrentDirectory( ), @"DirectoryTest\FileTest1.txt"); string targetFilePath = Path.Combine(Path.GetTempPath( ), "FileTest1.txt"); if (!File.Exists(sourceFilePath)) { Assert.Fail(string.Format("File {0} does not exists", sourceFilePath)); return; } Stream outStream = null; try { outStream = ZipFiles.Compress(sourceFilePath); if (outStream == null) { Assert.Fail("File cannot be compressed."); return; } if (File.Exists(targetFilePath)) { File.Delete(targetFilePath); } ZipFiles.DecompressFile(Path.GetTempPath( ), outStream); } finally { if (outStream != null) { outStream.Close( ); } } Assert.AreEqual(Directory.GetFiles(Path.GetTempPath( ), "FileTest1.txt").Length, 1); }
public void Backup( CompressionLevel compressionLevel, string[] sources, string destination, bool complyToGitIgnore, Func <bool> isCancellationRequested, Action onCompleted, Action <string> onStatusChanged) { try { foreach (var source in sources) { var destFile = Path.Combine(destination, Path.GetFileName(source)); string destZipfile; var n = 0; do { destZipfile = string.Concat(destFile, DateTime.Now.ToString("-yyyyMMdd"), n == 0 ? "" : $"-({n})", ".zip"); n++; } while (File.Exists(destZipfile)); var excludedFilesPredicate = complyToGitIgnore ? CreateExcludePredicateFromGitignore(source) : (_) => false; var zip = new ZipFiles(); zip.StatusEvent += (_, ev) => onStatusChanged(ev.StatusMessage); zip.Create(compressionLevel, source, destZipfile, isCancellationRequested, true, excludedFilesPredicate); } } finally { onCompleted(); } }
private void MergeFiles(string machine, TaskInfo task) { Logger.AddTrace("Merging Shared Task"); string targetZipFile; string sharedPath = FileUtilities.GetAbsolutePath(task.GetSharedPath()); string targetPath = Path.Combine(Path.GetTempPath(), task.Id.ToString()); if (!ViewsManager.DownloadTaskFile(machine, task, out targetZipFile, task.GetSharedPath())) { return; } //clean temporal path before decompress new files if (Directory.Exists(targetPath)) { Directory.Delete(targetPath, true); } try { ZipFiles.Decompress(targetPath, targetZipFile); } catch (Exception e) { Logger.AddException(e); } bool isDirectory = string.IsNullOrEmpty(Path.GetExtension(sharedPath)); if (!isDirectory) { targetPath = Path.Combine(targetPath, Path.GetFileName(sharedPath)); } FileUtilities.ForceCreateDirectory(sharedPath); this.ExecuteMergeTool(sharedPath, targetPath, isDirectory); }
private void OverwriteFiles(string machine, TaskInfo task) { Logger.AddTrace("Overwriting Files"); string targetZipFile; string sharedPath = FileUtilities.GetAbsolutePath(task.GetSharedPath()); string targetPath = Path.GetDirectoryName(sharedPath); if (!ViewsManager.DownloadTaskFile(machine, task, out targetZipFile, task.GetSharedPath())) { return; } try { ZipFiles.Decompress(targetPath, targetZipFile); } catch (Exception e) { Logger.AddException(e); } }
public void CreateZipFromDirectory(string sourceDirectoryName, string destinationArchiveFileName) => ZipFiles.Add(sourceDirectoryName, destinationArchiveFileName);
private void SavaData() { if (this.txtToDept.Value.Replace("#", "").Replace("undefined", "") == "") { ShowJsMessage("请选择发往单位"); return; } if (this.Session["EPORTID"].ToString() != "GWJT120911" && this.txtToDept.Value.Trim().IndexOf("TCGW111128") > -1)//只有集团可以向管委会发文 { ShowJsMessage("只有集团可以向管委会发文,请重新选择发往单位"); return; } List<FrameAttachment.DetailUploadFile> DUFList = new FrameAttachment().SelectFilesByGroupGuid2(this.ViewState["guid"].ToString()); string Att = ""; if (DUFList.Count > 0) { Att = DUFList[0].FilePath + DUFList[0].FileName; } new DocSendRegistDB().Insert(this.ViewState["guid"].ToString(), this.txtCode.Text.Trim(), Convert.ToDateTime(this.dtTime.Text.Trim()), DateTime.Now, this.txtTitle.Text.Trim(), this.txtContent.Text.Trim(), this.Session["UserID"].ToString(), this.Session["RealName"].ToString(), this.txtTo.Text.Trim(), this.txtToDept.Value.Trim(), Att, Session["EPORTID"].ToString(), Session["CompanyFullName"].ToString()); if (this.txtToDept.Value.Trim().IndexOf("TCGW111128") > -1)//向管委会发文 { try { string SendPath = System.Web.Configuration.WebConfigurationManager.AppSettings["GWHPATH"]; string XmlPath = System.Web.Configuration.WebConfigurationManager.AppSettings["XMLPATH"]; string ZipPwd = System.Web.Configuration.WebConfigurationManager.AppSettings["ZIPPWD"]; if (System.IO.Directory.Exists(SendPath)) { string[] FileList = new string[DUFList.Count]; string[] ZipFile = new string[DUFList.Count + 1]; for (int i = 0; i < DUFList.Count; i++) { FileList[i] = DUFList[i].FileName; ZipFile[i] = Server.MapPath(DUFList[0].FilePath + DUFList[0].FileName); } XmlPath = XmlPath +"\\"+ this.ViewState["guid"].ToString(); if (!System.IO.Directory.Exists(XmlPath)) { System.IO.Directory.CreateDirectory(XmlPath); } System.IO.File.AppendAllText(XmlPath + "\\Meta.xml", GetXmlContent(FileList)); ZipFile[DUFList.Count] = XmlPath + "\\Meta.xml"; bool bolFlag = new ZipFiles().ZipFileDictory(ZipFile, SendPath+"\\"+this.ViewState["guid"].ToString() + ".zip", ZipPwd); if (bolFlag == false) { ShowJsMessage("向管委会发文,生成压缩文件出错,向管委会发文失败"); return; } } } catch (Exception ex) { ShowJsMessage("向管委会发文发文失败,失败原因"+ex.Message); return; } } CallJsFun("alert('成功保存');window.close();"); }