使用winrar解压如何查看密码
Use winrar decompression how to check password
用winrar解压,如何检测密码是否正确?
the_Reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe");
the_Obj = the_Reg.GetValue("");
the_rar = the_Obj.ToString();
the_Reg.Close();
the_Info = "x " + rarName + " " + _unRarPath + " -y -p123456";
ProcessStartInfo the_StartInfo = new ProcessStartInfo();
the_StartInfo.FileName = the_rar;
the_StartInfo.Arguments = the_Info;
the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
the_StartInfo.WorkingDirectory = _rarPath;//获取压缩包路径
Process the_Process = new Process();
the_Process.StartInfo = the_StartInfo;
the_Process.Start();
the_Process.WaitForExit();
希望此解决方案对您有所帮助。这里是原文postLink
public class ZipPasswordTester
{
public bool CheckPassword(Ionic.Zip.ZipEntry entry, string password)
{
try
{
using (var s = new PasswordCheckStream())
{
entry.ExtractWithPassword(s, password);
}
return true;
}
catch (Ionic.Zip.BadPasswordException)
{
return false;
}
catch (PasswordCheckStream.GoodPasswordException)
{
return true;
}
}
private class PasswordCheckStream : System.IO.MemoryStream
{
public override void Write(byte[] buffer, int offset, int count)
{
throw new GoodPasswordException();
}
public class GoodPasswordException : System.Exception { }
}
}
用winrar解压,如何检测密码是否正确?
the_Reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe");
the_Obj = the_Reg.GetValue("");
the_rar = the_Obj.ToString();
the_Reg.Close();
the_Info = "x " + rarName + " " + _unRarPath + " -y -p123456";
ProcessStartInfo the_StartInfo = new ProcessStartInfo();
the_StartInfo.FileName = the_rar;
the_StartInfo.Arguments = the_Info;
the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
the_StartInfo.WorkingDirectory = _rarPath;//获取压缩包路径
Process the_Process = new Process();
the_Process.StartInfo = the_StartInfo;
the_Process.Start();
the_Process.WaitForExit();
希望此解决方案对您有所帮助。这里是原文postLink
public class ZipPasswordTester
{
public bool CheckPassword(Ionic.Zip.ZipEntry entry, string password)
{
try
{
using (var s = new PasswordCheckStream())
{
entry.ExtractWithPassword(s, password);
}
return true;
}
catch (Ionic.Zip.BadPasswordException)
{
return false;
}
catch (PasswordCheckStream.GoodPasswordException)
{
return true;
}
}
private class PasswordCheckStream : System.IO.MemoryStream
{
public override void Write(byte[] buffer, int offset, int count)
{
throw new GoodPasswordException();
}
public class GoodPasswordException : System.Exception { }
}
}