成熟丰满熟妇高潮XXXXX,人妻无码AV中文系列久久兔费 ,国产精品一国产精品,国精品午夜福利视频不卡麻豆

您好,歡迎來到九壹網(wǎng)。
搜索
您的當前位置:首頁C#關(guān)于RAR,ZIP的操作

C#關(guān)于RAR,ZIP的操作

來源:九壹網(wǎng)

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;
using Microsoft.Win32;
namespace RarClass
{
??? public class unrar
??? {
??? public void unCompressRAR(string unRarPatch, string rarPatch, string rarName)
??????? {
??????????? string the_rar;
??????????? RegistryKey the_Reg;
??????????? object the_Obj;
??????????? string the_Info;

??????????????? 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_rar = the_rar.Substring(1, the_rar.Length – 7);

??????????????? if (Directory.Exists(unRarPatch) == false)
??????????????? {
??????????????????? Directory.CreateDirectory(unRarPatch);
??????????????? }
??????????????? the_Info = “x? -y? ” + rarName + ” ” + unRarPatch ;
??????????????? ProcessStartInfo the_StartInfo = new ProcessStartInfo();
??????????????? the_StartInfo.FileName = the_rar;
??????????????? the_StartInfo.Arguments = the_Info;
??????????????? the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
??????????????? the_StartInfo.WorkingDirectory = rarPatch;//獲取壓縮包路徑

??????????????? Process the_Process = new Process();
??????????????? the_Process.StartInfo = the_StartInfo;
??????????????? the_Process.Start();
??????????????? the_Process.WaitForExit();
??????????????? the_Process.Close();
???????????????
???????????
??????? }
??? }
}

2.

????????????????Directory.CreateDirectory(path);
????????????????

????????????????startinfo.WorkingDirectory?

?

昨天又看了下,發(fā)現(xiàn)如果路徑中有空格(如:D:\Program Files\)的話壓縮解壓就會出現(xiàn)問題,折磨了我很長時間,最后實在沒辦法了就在cmd里面試了半天,發(fā)現(xiàn)在有空格的路徑上加雙引號就可以了。在代碼里Directory.CreateDirectory(path);后面把 path 和?rarName 都判斷一下如果有空格,就加上 path = “\”" + path + “\”";

?

3.

? c#與RAR 收藏
本次示例主要實現(xiàn):
1.壓縮文件夾及其下文件
2.壓縮文件夾下文件
3.壓縮文件夾及其下文件為rar 還是 zip
4.解壓縮
5.加密壓縮及解加密壓縮
———–
示例代碼如下:
protected void Button1_Click(object sender, EventArgs e)
??? {
??????? string strtxtPath = “C:\\freezip\\free.txt”;
??????? string strzipPath = “C:\\freezip\\free.zip”;
??????? System.Diagnostics.Process Process1 = new System.Diagnostics.Process();
??????? Process1.StartInfo.FileName = “Winrar.exe”;
??????? Process1.StartInfo.CreateNoWindow = true;

??????? 1
??????? 壓縮c:\freezip\free.txt(即文件夾及其下文件freezip\free.txt)
??????? 到c:\freezip\free.rar
??????? //strzipPath = “C:\\freezip\\free”;//默認壓縮方式為 .rar
??????? //Process1.StartInfo.Arguments = ” a -r ” + strzipPath + ” ” + strtxtPath;

??????? 2
??????? 壓縮c:\freezip\free.txt(即文件夾及其下文件freezip\free.txt)
??????? 到c:\freezip\free.rar
??????? //strzipPath = “C:\\freezip\\free”;//設(shè)置壓縮方式為 .zip
??????? //Process1.StartInfo.Arguments = ” a -afzip ” + strzipPath + ” ” + strtxtPath;

??????? 3
??????? 壓縮c:\freezip\free.txt(即文件夾及其下文件freezip\free.txt)
??????? 到c:\freezip\free.zip 直接設(shè)定為free.zip
??????? //Process1.StartInfo.Arguments = ” a -r “+strzipPath+” ” + strtxtPath ;

??????? 4
??????? 搬遷壓縮c:\freezip\free.txt(即文件夾及其下文件freezip\free.txt)
??????? 到c:\freezip\free.rar 壓縮后 原文件將不存在
??????? //Process1.StartInfo.Arguments = ” m ” + strzipPath + ” ” + strtxtPath;

??????? 5
??????? 壓縮c:\freezip\下的free.txt(即文件free.txt)
??????? 到c:\freezip\free.zip 直接設(shè)定為free.zip 只有文件 而沒有文件夾
??????? //Process1.StartInfo.Arguments = ” a -ep ” + strzipPath + ” ” + strtxtPath;

??????? 6
??????? 解壓縮c:\freezip\free.rar
??????? 到 c:\freezip\
??????? //strtxtPath = “c:\\freezip\\”;
??????? //Process1.StartInfo.Arguments = ” x ” + strzipPath + ” ” + strtxtPath;

??????? 7
??????? 加密壓縮c:\freezip\free.txt(即文件夾及其下文件freezip\free.txt)
??????? 到c:\freezip\free.zip 密碼為123456 注意參數(shù)間不要空格
??????? //Process1.StartInfo.Arguments = ” a -p123456 ” + strzipPath + ” ” + strtxtPath;

??????? 8
??????? 解壓縮加密的c:\freezip\free.rar
??????? 到 c:\freezip\?? 密碼為123456 注意參數(shù)間不要空格
??????? //strtxtPath = “c:\\freezip\\”;
??????? //Process1.StartInfo.Arguments = ” x -p123456 ” + strzipPath + ” ” + strtxtPath;

?????? 9
?????? -o+ 覆蓋 已經(jīng)存在的文件
?????? -o- 不覆蓋 已經(jīng)存在的文件
?????? //strtxtPath = “c:\\freezip\\”;
?????? //Process1.StartInfo.Arguments = ” x -o+ ” + strzipPath + ” ” + strtxtPath;

?????? 10
?????? 只從指定的zip中
?????? 解壓出free1.txt
?????? 到指定路徑下
?????? 壓縮包中的其他文件 不予解壓
?????? //strtxtPath = “c:\\freezip\\”;
?????? //Process1.StartInfo.Arguments = ” x ” + strzipPath + ” ” +” free1.txt” + ” ” + strtxtPath;

?????? 11
?????? 通過 -y 對所有詢問回應(yīng)為”是” 以便 即便發(fā)生錯誤 也不彈出WINRAR的窗口
?????? -cl 轉(zhuǎn)換文件名為小寫字母
?????? //strtxtPath = “c:\\freezip\\”;
?????? //Process1.StartInfo.Arguments = ” t -y -cl ” + strzipPath + ” ” + ” free1.txt”;

??????? Process1.Start();???
??????? if (Process1.HasExited)
??????? {
?????????????? int iExitCode = Process1.ExitCode;
??????????????? if (iExitCode == 0)
??????????????? {
??????????????????? Response.Write(iExitCode.ToString() + ” 正常完成”);
??????????????? }
??????????????? else
??????????????? {
??????????????????? Response.Write(iExitCode.ToString() + ” 有錯完成”);
??????????????? }
??????? }
??? }

4.

C#調(diào)用rar.exe解壓一個rar文件到系統(tǒng)的臨時目錄

?

//C#調(diào)用rar.exe解壓一個rar文件到系統(tǒng)的臨時目錄:
//取得系統(tǒng)臨時目錄
string sysTempDir = Path.GetTempPath();

?

//要解壓的文件路徑,請自行設(shè)置
string rarFilePath = @”d:\test.rar”;

//組合出需要shell的完整格式
string shellArguments = string.Format(“x -o+ \”{0}\” \”{1}\\\”",
??? rarFilePath, unrarDestPath);

//用Process調(diào)用
using (Process unrar = new Process())
{
??? unrar.StartInfo.FileName = “rar.exe”;
??? unrar.StartInfo.Arguments = shellArguments;
??? //隱藏rar本身的窗口
??? unrar.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
??? unrar.Start();
??? //等待解壓完成
??? unrar.WaitForExit();
??? unrar.Close();
}

轉(zhuǎn)載于:https://www.cnblogs.com/yanghb/archive/2010/08/06/1793877.html

因篇幅問題不能全部顯示,請點此查看更多更全內(nèi)容

Copyright ? 2019- 91gzw.com 版權(quán)所有 湘ICP備2023023988號-2

違法及侵權(quán)請聯(lián)系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市萬商天勤律師事務(wù)所王興未律師提供法律服務(wù)