1. 지정한 폴더의 필터를 걸어 파일의 리스트를 가져온다.
2. 해당 파일들을 압축한다.
3. 압축한 파일들을 삭제한다.
public List<string> GetDirectoryFileList(string directory, string filter) { if (Directory.Exists(directory)) { DirectoryInfo di = new DirectoryInfo(directory); List<string> fileNames = new List<string>(); foreach (var file in di.GetFiles(filter)) { fileNames.Add(file.Name); } return fileNames; } else { return null; } } public void DeleteFile(string file) { try { File.Delete(file); } catch (FileNotFoundException) { return; } } //archiveFileDirectory : 압축하고 싶은 파일들이 있는 경로 //archivedDirectoryFileName : 압축파일경로 및 이름 //filter : 압축하고 싶은 파일이름 필터 ex) *.json public void Archive(string archiveFileDirectory, string archivedDirectoryFileName, string filter) { if (GetDirectoryFileList(archiveFileDirectory, filter).Count == 0) { return; } using (FileStream zipToOpen = new FileStream($"{archivedDirectoryFileName}.zip", FileMode.CreateNew)) { using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Create)) { foreach (var filePath in Directory.EnumerateFiles(archiveFileDirectory, filter)) { ZipFileExtensions.CreateEntryFromFile(archive, filePath, filePath.Substring(filePath.LastIndexOf("/"))); DeleteFile(filePath); } } } } | cs |
2 댓글
The Best Slots and the Best Payout Slots By Payout Types - DrMCD
답글삭제In the gambling 밀양 출장안마 world, งานออนไลน์ these casinos often offer a free 구리 출장마사지 spins bonus that is usually awarded to certain players as a 경기도 출장샵 free 진주 출장샵 money bonus. A free spins
These exams confirm if a product is developed appropriately or if it must be modified to fulfill its necessities. The RDF representation of 3D models can be utilized in reasoning, which permits intelligent 3D applications which, for example, can routinely compare two 3D models by volume. The first widely obtainable commercial utility of human virtual models appeared in 1998 CNC machining on the Lands' End website online. The human virtual models were created by the corporate My Virtual Mode Inc. and enabled customers to create a model of themselves and check out|and take a look at} on 3D clothes. There are quantity of} fashionable programs that permit for the creation of virtual human models . Modeling can be carried out via a devoted program (e.g., Blender, Cinema 4D, LightWave, Maya, Modo, 3ds Max) or an utility part or some scene description language (as in POV-Ray).
답글삭제