일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- nullable
- convert
- windows
- string
- ListView
- File
- tls
- 코딩테스트
- Binding
- C#
- git
- windows10
- programmers
- dotNET
- Github
- WPF
- log
- commit
- .net
- Microsoft
- coding-test
- Coding
- Process
- Visual Studio
- IValueConverter
- csharp
- chashtag
- logging
- algorithm
- mysql
- Today
- Total
CHashtag
[C#] 압축, 압축 풀기 with 비밀번호 (zip, unzip with password) 본문
안녕하세요.
오늘은 https://chashtag.tistory.com/24 에 이어 비밀번호와 함께 압축, 압축을 푸는 방법에 대해 알아보도록 하겠습니다.
[C#] 압축, 압축 풀기 (zip, unzip)
오늘은 폴더를 zip 파일로, zip 파일을 폴더로 만드는 방법에 대해 알아보겠습니다. 아래 코드를 구현하기 위해선 System.IO.Compression.FileSystem을 Reference에 추가하여야 합니다. static void Main(string[..
chashtag.tistory.com
위 링크에서는 System.IO.Compression 의 ZipFile Class를 사용했었는데요, 하지만 이 Class에서는 비밀번호를 이용해 zip, unzip 기능을 제공하지 않습니다.
unzip password protected .zip files in directory
Hi arkiboys, About the error, you could first use try-catch to record the error message and then to find out the issue point. For your code above, I think you’d better use the below code to check whether the password is provided or not. if (!string.IsNul
social.msdn.microsoft.com
그렇기 때문에 오늘은 "dotnetzip" 이라는 무료 라이브러리를 이용하여 코드를 구현해 보도록 하겠습니다.
(라이센스: Microsoft Public License, 프로젝트 URL: https://github.com/haf/DotNetZip.Semverd)
GitHub - haf/DotNetZip.Semverd: A fork of the DotNetZip project without signing with a solution that compiles cleanly. This proj
A fork of the DotNetZip project without signing with a solution that compiles cleanly. This project aims to follow semver to avoid versioning conflicts. DotNetZip is a FAST, FREE class library and...
github.com
Code
using Ionic.Zip;
public void Zip(string directoryPath, string zipPath, string password = null)
{
using (ZipFile zip = new ZipFile(zipPath))
{
zip.Password = password;
zip.AddFile(directoryPath, string.Empty);
zip.Save(zipPath);
}
}
public void UnZip(string zipFilePath, string unZipPath, string password = null)
{
using (ZipFile zip = new ZipFile(zipFilePath))
{
zip.Password = password;
zip.ExtractAll(unZipPath);
}
}
전체 코드는 아래 링크에서 확인하실 수 있습니다.
https://github.com/Hyo-Seong/CHashtag/tree/master/zip_unzip_with_password
GitHub - Hyo-Seong/CHashtag: https://chashtag.tistory.com/
https://chashtag.tistory.com/. Contribute to Hyo-Seong/CHashtag development by creating an account on GitHub.
github.com
감사합니다.
'C#' 카테고리의 다른 글
[C#] 실행시간 측정하기 (Stopwatch) (0) | 2021.12.16 |
---|---|
Visual Studio에서 솔루션 내 프로젝트 동시 실행(debug multiple project) (0) | 2021.11.13 |
[C#] 폴더 크기 구하기 (Get Directory Size) (1) | 2021.07.01 |
[C#] Mutex 생성, 해제하기 (중복실행방지) (Lock) (0) | 2021.06.30 |
[C#] CallerMemberName Attribute 사용법 (0) | 2021.06.30 |