tôi đã cùng một vấn đề và giải quyết nó bằng cách gọi thực thi 7-zip qua vỏ cmd từ C# mã, như sau,
string zipped_path = "xxx.7z";
string unzipped_path = "yyy";
string arguments = "e " + zipped_path + " -o" + unzipped_path;
System.Diagnostics.Process process
= Launch_in_Shell("C:\\Program Files (x86)\\7-Zip\\","7z.exe", arguments);
if (!(process.ExitCode == 0))
throw new Exception("Unable to decompress file: " + zipped_path);
Và nơi Launch_in_Shell(...)
được định nghĩa là,
public static System.Diagnostics.Process Launch_in_Shell(string WorkingDirectory,
string FileName,
string Arguments)
{
System.Diagnostics.ProcessStartInfo processInfo
= new System.Diagnostics.ProcessStartInfo();
processInfo.WorkingDirectory = WorkingDirectory;
processInfo.FileName = FileName;
processInfo.Arguments = Arguments;
processInfo.UseShellExecute = true;
System.Diagnostics.Process process
= System.Diagnostics.Process.Start(processInfo);
return process;
}
Nhược điểm : Bạn cần cài đặt 7zip trong máy của bạn và tôi chỉ thử với các tệp ".7z". Hi vọng điêu nay co ich.
Bạn có thể tìm hiểu về định dạng zip và viết codec riêng nếu bạn chống lại thư viện của bên thứ ba và yêu xp quá nhiều = D – Sinatr