일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 |
- SERIAL
- Overloading
- aduino
- file access
- memory
- Read
- preprocessing
- java
- sensor
- public
- c++
- Encapusulation
- flutter
- Unity
- mfc
- Barcode
- length
- compare
- APP
- digitalRead
- atmega328
- Class
- UNO
- wpf
- parameter
- Pointer
- stream
- Android
- Contour
- inheritance
- Today
- Total
폴크(FOLC)
C# 테크닉 - UnZip 파일 복원 ( SharpZipLib ) 본문
C# 테크닉 - UnZip 파일 복원 ( SharpZipLib )
folcjin 2021. 12. 6. 21:07# Local 폴더를 Zip 파일을 복원
> SharpZipLib 라이브러리 이용
# Nuget 에서 SharpZipLib 설치

# 소스 코드
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
public void UnZipFileWithDecompress(string src_path, string dst_path)
{
DirectoryInfo dst_dir_info = new DirectoryInfo(dst_path);
if (dst_dir_info.Exists == false)
{
dst_dir_info.Create();
}
FileStream src_file_stream = new FileStream(src_path, FileMode.Open);
ZipInputStream zip_strm = new ZipInputStream(src_file_stream);
byte[] databufferArray = new byte[1024];
while (true)
{
ZipEntry zipEntry = zip_strm.GetNextEntry();
if (zipEntry == null)
{
break;
}
if (0 < zipEntry.Name.LastIndexOf('\\'))
{
string sub_dir = zipEntry.Name.Substring(0, zipEntry.Name.LastIndexOf('\\'));
if (Directory.Exists(Path.Combine(dst_dir_info.FullName, sub_dir)) == false)
{
dst_dir_info.CreateSubdirectory(sub_dir);
}
}
FileInfo dst_file_info = new FileInfo(Path.Combine(dst_dir_info.FullName, zipEntry.Name));
using (FileStream dst_file_stream = dst_file_info.Create())
{
while (true)
{
int datacount = zip_strm.Read(databufferArray, 0, databufferArray.Length);
if (datacount == 0)
{
break;
}
dst_file_stream.Write(databufferArray, 0, datacount);
}
}
}
zip_strm.Close();
}
'C#, WF, WPF(.NET) > C#, WF, WPF(.NET) 테크닉' 카테고리의 다른 글
C# 테크닉 - NetworkDrive (0) | 2021.12.08 |
---|---|
C# 테크닉 - TimeCheck ( QPC ) (0) | 2021.12.07 |
C# 테크닉 - Zip 파일 생성( SharpZipLib ) (0) | 2021.12.06 |
C# 테크닉 - FTP FileDownload ( WebRequest ) (0) | 2021.12.05 |
C# 테크닉 - FTP FileUpload ( WebRequest ) (0) | 2021.12.05 |