c#調(diào)用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>");
}
相關(guān)文章
C# LINQ查詢表達(dá)式及對(duì)應(yīng)LAMBDA表達(dá)式的用法
這篇文章主要介紹了C# LINQ查詢表達(dá)式及對(duì)應(yīng)LAMBDA表達(dá)式的用法,幫助大家更好的理解和學(xué)習(xí)使用c#,感興趣的朋友可以了解下2021-04-04c#后臺(tái)線程訪問(wèn)前臺(tái)控件并顯示信息示例
這篇文章主要介紹了c#后臺(tái)線程訪問(wèn)前臺(tái)控件并顯示信息示例,需要的朋友可以參考下2014-03-03C#實(shí)現(xiàn)DVD借出歸還管理系統(tǒng)
這篇文章主要介紹了C#實(shí)現(xiàn)DVD借出歸還管理系統(tǒng),類似DVD管理器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-06-06C#中System.Text.Json匿名對(duì)象反序列化
這篇文章主要介紹了System.Text.Json匿名對(duì)象反序列化,下文代碼基于. NET 6,為了代碼整潔,實(shí)際配置了PropertyNameCaseInsensitive = true,本文結(jié)合實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-05-05C# Winform實(shí)現(xiàn)石頭剪刀布游戲
這篇文章主要為大家詳細(xì)介紹了Winform實(shí)現(xiàn)石頭剪刀布游戲,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-01-01使用C#實(shí)現(xiàn)網(wǎng)頁(yè)內(nèi)容保存為圖片并生成壓縮包
這篇文章主要為大家詳細(xì)介紹了如何使用C#實(shí)現(xiàn)網(wǎng)頁(yè)內(nèi)容保存為圖片并生成壓縮包,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-02-02微信公眾號(hào)被動(dòng)消息回復(fù)原理解析
這篇文章主要介紹了公眾號(hào)被動(dòng)消息回復(fù)原理解析,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-06-06