国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net中調用winrar實現壓縮解壓縮的代碼

2024-07-10 12:39:43
字體:
來源:轉載
供稿:網友

asp.net壓縮文件夾調用示例:rar("e:/www.survivalescaperooms.com/", "e:/www.survivalescaperooms.com.rar");
asp.net解壓縮rar文件調用示例:unrar("e:/www.survivalescaperooms.com.rar", "e:/");
代碼如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace BLL
{
public class CmdUtil
{
///
/// 執行cmd.exe命令
///
///命令文本
/// 命令輸出文本
public static string ExeCommand(string commandText)
{
return ExeCommand(new string[] { commandText });
}
///
/// 執行多條cmd.exe命令
///
///命令文本數組
/// 命令輸出文本
public static string ExeCommand(string[] commandTexts)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
string strOutput = null;
try
{
p.Start();
foreach (string item in commandTexts)
{
p.StandardInput.WriteLine(item);
}
p.StandardInput.WriteLine("exit");
strOutput = p.StandardOutput.ReadToEnd();
//strOutput = Encoding.UTF8.GetString(Encoding.Default.GetBytes(strOutput));
p.WaitForExit();
p.Close();
}
catch (Exception e)
{
strOutput = e.Message;
}
return strOutput;
}
///
/// 啟動外部Windows應用程序,隱藏程序界面
///
///應用程序路徑名稱
/// true表示成功,false表示失敗
public static bool StartApp(string appName)
{
return StartApp(appName, ProcessWindowStyle.Hidden);
}
///
/// 啟動外部應用程序
///
///應用程序路徑名稱
///進程窗口模式
/// true表示成功,false表示失敗
public static bool StartApp(string appName, ProcessWindowStyle style)
{
return StartApp(appName, null, style);
}
///
/// 啟動外部應用程序,隱藏程序界面
///
///應用程序路徑名稱
///啟動參數
/// true表示成功,false表示失敗
public static bool StartApp(string appName, string arguments)
{
return StartApp(appName, arguments, ProcessWindowStyle.Hidden);
}
///
/// 啟動外部應用程序
///
///應用程序路徑名稱
///啟動參數
///進程窗口模式
/// true表示成功,false表示失敗
public static bool StartApp(string appName, string arguments, ProcessWindowStyle style)
{
bool blnRst = false;
Process p = new Process();
p.StartInfo.FileName = appName;//exe,bat and so on
p.StartInfo.WindowStyle = style;
p.StartInfo.Arguments = arguments;
try
{
p.Start();
p.WaitForExit();
p.Close();
blnRst = true;
}
catch
{
}
return blnRst;
}

public static void Rar(string s, string d)
{
ExeCommand(System.Web.HttpContext.Current.Server.MapPath("~/rar.exe") + " a /"" + d + "/" /"" + s + "/" -ep1");

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 涿州市| 石屏县| 金寨县| 普安县| 丹巴县| 海晏县| 方山县| 兴隆县| 永州市| 江山市| 手机| 滨州市| 卓尼县| 高碑店市| 册亨县| 平远县| 格尔木市| 巴中市| 广德县| 湄潭县| 安庆市| 新晃| 丹江口市| 固安县| 临海市| 界首市| 玉龙| 尚志市| 新田县| 左云县| 塔河县| 抚松县| 浏阳市| 穆棱市| 中西区| 宜春市| 鲁山县| 拜城县| 磴口县| 嵊泗县| 阳城县|