c#调用winrar解压缩文件代码分享


using Microsoft.Win32;
using System.Diagnostics;
压缩
string the_rar;
RegistryKey the_Reg;
object the_Obj;
string the_Info;
processstartinfo the_StartInfo;
Process the_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 = new processstartinfo();


the_StartInfo.FileName = the_rar;
the_StartInfo.Arguments = the_Info;
the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
the_StartInfo.WorkingDirectory = @"C:\test\";
the_Process = new Process();
the_Process.StartInfo = the_StartInfo;
the_Process.Start();
Response.Write("<script>alert('Zip Successfully');</script>");
}
catch
{
Response.Write("<script>alert('Zip Failed.')</script>");
}

解压缩


string the_rar;
RegistryKey the_Reg;
object the_Obj;
string the_Info;
processstartinfo the_StartInfo;
Process the_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 = new processstartinfo();


the_StartInfo.FileName = the_rar;
the_StartInfo.Arguments = the_Info;
the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
the_StartInfo.WorkingDirectory = @"C:\test\";
the_Process = new Process();
the_Process.StartInfo = the_StartInfo;
the_Process.Start();
Response.Write("<script>alert('UnZip Successfully');</script>");
}
catch
{
Response.Write("<script>alert('UnZip Failed.')</script>");
}

相关文章

目录简介使用JS互操作使用ClipLazor库创建项目使用方法简单测...
目录简介快速入门安装 NuGet 包实体类User数据库类DbFactory...
本文实现一个简单的配置类,原理比较简单,适用于一些小型项...
C#中Description特性主要用于枚举和属性,方法比较简单,记录...
[TOC] # 原理简介 本文参考[C#/WPF/WinForm/程序实现软件开机...
目录简介获取 HTML 文档解析 HTML 文档测试补充:使用 CSS 选...