????????????
Contents
[
Hide
Show
]???????? ?????
???????????????????????????????????? zip ??????????????????? CompressionProgressed ???? ?????????????????????????????? ProgressEventArgs ??????? ???? ???? ??????????????????????????
1 ????.CompressionProgressed += (s, e) => {
2 Console.WriteLine(string.Format("{0} ?????", e.ProceededBytes));
3 };Zip ????????
CompressionProgressed ?????????????ProceededBytes ??????????????????????????????????????????????????????????????
- File.Open ????? huge.bin ??????????????????????????
- ??? PPMdCompressionSettings ??????Archive ?????????????????????
- CreateEntry ????????? huge.bin ?????????? ???????????? ???? ?????????????
- ???? ?????? CompressionProgressed ??????????????????????????????????????????????????
- ???? ?????????????????????????????????????????????
- ??????????????????? zipFile ???????
1 using (FileStream ??? = File.Open("huge.bin", FileMode.Open, FileAccess.Read))
2 {
3 using (var archive = new Archive(new ArchiveEntrySettings(new PPMdCompressionSettings())))
4 {
5 ArchiveEntry ???? = archive.CreateEntry("huge.bin", ???);
6 int ??????? = 0;
7 ????.CompressionProgressed += (s, e) =>
8 {
9 int ????? = (int)((100 * (long)e.ProceededBytes) / source.Length);
10 if (????? > ?????????)
11 {
12 Console.WriteLine(string.Format("{0}% ??", ?????));
13 ??????? = ?????;
14 }
15 };
16 archive.Save(zipFile);
17 }
18 }7z ?????????
7z ????????????????????????????????? CompressionProgressed ???? ??????
??: C# ? 7z ?????? LZMA2 ???????????????</?>
- ??? ???? (huge.bin) ??????????????
- LZMA2 ????????? SevenZipArchive ?????????????
- CreateEntry ????????????? ????????????????????????
- CompressionProgressed ??????????????????????????????????
- ??????????????????????????????
- ????????????? (zipFile) ???????
1using (FileStream ??? = File.Open("huge.bin", FileMode.Open, FileAccess.Read))
2 {
3 using (var archive = new SevenZipArchive(new SevenZipEntrySettings(new SevenZipLZMA2CompressionSettings())))
4 {
5 SevenZipArchiveEntry ???? = archive.CreateEntry("huge.bin", ???);
6 int ??????? = 0;
7 entry.CompressionProgressed += ????? (?????? s?ProgressEventArgs e)
8 {
9 // ? SevenZipArchiveEntry ??
10 int ????? = (int)((100 * (long)e.ProceededBytes) / source.Length);
11 if (????? > ?????????)
12 {
13 ??????? = ?????;
14 }
15 };
16 archive.Save(zipFile);
17 }
18 }