c#调用winrar解压缩文件代码分享
usingMicrosoft.Win32;
usingSystem.Diagnostics;
压缩
stringthe_rar;
RegistryKeythe_Reg;
objectthe_Obj;
stringthe_Info;
ProcessStartInfothe_StartInfo;
Processthe_Process;
try
{
the_Reg=Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command");
the_Obj=the_Reg.GetValue("");
the_rar=the_Obj.ToString();
the_Reg.Close();
the_rar=the_rar.Substring(1,the_rar.Length-7);
the_Info="a"+"test.rar"+""+@"C:\test\test.txt";
the_StartInfo=newProcessStartInfo();
the_StartInfo.FileName=the_rar;
the_StartInfo.Arguments=the_Info;
the_StartInfo.WindowStyle=ProcessWindowStyle.Hidden;
the_StartInfo.WorkingDirectory=@"C:\test\";
the_Process=newProcess();
the_Process.StartInfo=the_StartInfo;
the_Process.Start();
Response.Write("<script>alert("ZipSuccessfully");</script>");
}
catch
{
Response.Write("<script>alert("ZipFailed.")</script>");
}
解压缩
stringthe_rar;
RegistryKeythe_Reg;
objectthe_Obj;
stringthe_Info;
ProcessStartInfothe_StartInfo;
Processthe_Process;
try
{
the_Reg=Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command");
the_Obj=the_Reg.GetValue("");
the_rar=the_Obj.ToString();
the_Reg.Close();
the_rar=the_rar.Substring(1,the_rar.Length-7);
the_Info="X"+"test.rar"+@"C:\test\";
the_StartInfo=newProcessStartInfo();
the_StartInfo.FileName=the_rar;
the_StartInfo.Arguments=the_Info;
the_StartInfo.WindowStyle=ProcessWindowStyle.Hidden;
the_StartInfo.WorkingDirectory=@"C:\test\";
the_Process=newProcess();
the_Process.StartInfo=the_StartInfo;
the_Process.Start();
Response.Write("<script>alert("UnZipSuccessfully");</script>");
}
catch
{
Response.Write("<script>alert("UnZipFailed.")</script>");
}
相关文章
- Camstar开发C#代码规范、Camstar更新以及Designer 开发规范
- 【地铁上的Redis与C#】数据类型(八)--List类型操作注意事项与常见业务场景
- asp.net(c#)文件下载实现代码
- asp.net(C#)解析Json的类代码
- c#完美截断字符串代码(中文+非中文)
- 关于C#.netwinform程序验证moss的集成身份认证实例
- C#实现Web文件上传的两种方法实例代码
- C#使用非托管代码直接修改字符串的方法
- C#获取全部目录和文件的简单实例
- 不能在子类或外部类发布C#事件代码分析
- C#实现打印与打印预览功能的思路及代码
- c#在windows服务中使用定时器实例代码
- c#中文gbk编码查询示例代码
- c#调用qq邮箱smtp发送邮件修改版代码分享
- C#判断数据类型的简单示例代码
- C#中判断字符串是全角还是半角的实现代码
- C#字符串的常用操作工具类代码分享
- C#实现闹钟AlarmClock实例代码
- C#实现压缩HTML代码的方法