c# - 如何在使用 c# 和 System.IO.Compression 压缩 zip 文件时取得进展
问题描述
我需要在使用带有 System.IO.Compression 的 C# 压缩 zip 文件时获取 %。我有这个代码:
if (isDirectory) {
Invoke(new RefreshConsoleEncryptionDel(RefreshConsoleEncryption), "[+]Wait, compressing folder...");
ZipFile.CreateFromDirectory(FileName, FileName + "_DirEnc.zip");
Invoke(new RefreshProcessBar1Del(RefreshProcessBar1), 100);
Invoke(new RefreshConsoleEncryptionDel(RefreshConsoleEncryption), "[✓]COMPLETED");
Invoke(new RefreshConsoleEncryptionDel(RefreshConsoleEncryption), "[K]Starting encrypting file...");
byte[] BytePasswordArray = IsFile ? File.ReadAllBytes(Password) : Encoding.UTF8.GetBytes(Password); // We create the array who will contain all bytes of password, depending if its an file password or just a string;
// A simple ternary condition, who checks if is file or string password
FileEncryptProcess(5000000, FileName + "_DirEnc.zip", BytePasswordArray); // We call the function to encrypt the file.
// If all goes allright we continue, else this thread will be aborted and we cant continue to next line.
Thread.CurrentThread.Abort();// If we can continue, then all will be allright and we close this thread succesfully.
}
我需要用 Zip 压缩的百分比来更新 ProgressBar1。有可能的?
解决方案
推荐阅读
- java - 如何在jsp和servlet中下载文件?
- linux - linux下切换字符
- typescript - 使用打字稿时如何添加自定义扩展
- r - R: tmap 中的投影 robin
- firebase - 我可以用 firebase 注册一个新的网站域吗?
- javascript - React-Native Flatlist 使用 Firebase 实时数据库加载更多
- swift - Swift - 如何计算字符串中特定字符的出现次数?
- c++ - 二维数组之和
- java - 给定总和的子集计数
- .net-core-3.1 - EmbeddedProvider.GetDirectoryContents 返回 0 个结果