壓縮文件夾c
⑴ 怎麼把文件壓縮
您好,首先電腦需要安裝一款壓縮軟體,安裝後的操作步驟如下:
1、將要壓縮的文件放置於同一個文件夾下;
2、選定要壓縮的文件;
⑵ C#調用winrar壓縮文件夾
要先引入using Microsoft.Win32;
/// <summary>
/// 壓縮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
ArrayList arrFiles = new ArrayList();
//要打包兩個文件和一個文件夾
arrFiles.Add(@"c:\abc.xls");
arrFiles.Add(@"d:\xyz.xls");
arrFiles.Add(@"e:\uvc");
//壓縮文件存放路徑
string savestr = @"c:\kugoo";
//壓縮文件名
string name = "test.rar";
this.CompressFileForReportTable(arrFiles, savestr, name);
}
/// <summary>
/// 壓縮文件
/// </summary>
/// <param name="sourceFilesPaths">要壓縮的文件路徑列表</param>
/// <param name="compressFileSavePath">壓縮文件存放路徑</param>
/// <param name="compressFileName">壓縮文件名(全名)</param>
p lic void CompressFileForReportTable(ArrayList sourceFilesPaths, string compressFileSavePath, string compressFileName)
{
String the_rar;
RegistryKey the_Reg;
System.Object the_Obj;
String the_Info;
ProcessStartInfo the_StartInfo;
Process the_Process;
try
{
//使用注冊表對象獲取到WiNRar路徑
the_Reg = Registry.ClassesRoot.OpenS Key(@"Applications\WinRAR.exe\Shell\Open\Command");
the_Obj = the_Reg.GetVal("");
the_rar = the_Obj.ToString();
the_Reg.Close();
the_rar = the_rar.S string(1, the_rar.Length - 7);
the_Info = " a " + compressFileName;
foreach (object filePath in sourceFilesPaths)
{
the_Info += " " + filePath.ToString();//每個文件路徑要與其它的空格隔開
}
the_StartInfo = new ProcessStartInfo();
the_StartInfo.FileName = the_rar;
the_StartInfo.Arguments = the_Info;
the_StartInfo.WindowStyle = ProcessWindowStyle.Normal;//Hidden 隱藏樣式
the_StartInfo.WorkingDirectory = compressFileSavePath;//獲取或設置要啟動的進程的初始目錄。(RAR存放路徑)
the_Process = new Process();
the_Process.StartInfo = the_StartInfo;
the_Process.Start();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
/// <summary>
/// 解壓縮指定的rar文件。
/// </summary>
/// <param name="rarFileToDecompress">rar文件(絕對路徑)。</param>
/// <param name="directoryToSave">解壓縮保存的目錄。</param>
/// <param name="deleteRarFile">解壓縮後刪除rar文件。</param>
p lic void DecompressRAR(string rarFileToDecompress, string directoryToSave, bool deleteRarFile)
{
String the_rar;
RegistryKey the_Reg;
Object the_Obj;
the_Reg = Registry.ClassesRoot.OpenS Key(@"Applications\WinRAR.exe\Shell\Open\Command");
the_Obj = the_Reg.GetVal("");
the_rar = the_Obj.ToString();
the_Reg.Close();
the_rar = the_rar.S string(1, the_rar.Length - 7);
string winrarExe = the_rar;//需要在指定路徑下放入winara.exe的可執行文件在安裝目錄下可以找到這個文件
if (new FileInfo(winrarExe).Exists)
{
//directoryToSave = CheckDirectoryName(directoryToSave);
try
{
Process p = new Process();
// 需要啟動的程序名
p.StartInfo.FileName = winrarExe;
// 參數
string arguments = @"x -inul -y -o+";
arguments += " " + rarFileToDecompress + " " + directoryToSave;
p.StartInfo.Arguments = arguments;
p.Start();//啟動
while (!p.HasExited)
{
}
p.WaitForExit();
}
catch (Exception ee)
{
throw new Exception("壓縮文件在解壓縮的過程中出現了錯誤!");
}
if (deleteRarFile)
{
File.Delete(rarFileToDecompress);
}
}
else
{
throw new Exception("本機上缺少必須的Winrar.exe文件,不能完成相應操作請聯系管理員安裝WinRar解壓工具!");
⑶ 如何用c語言壓縮解壓文件夾
你是想自己寫代碼實現解壓縮的功能,還是只是在代碼中調用命令來解壓,system()找到你的解壓縮工具在加相應的參數
⑷ 壓縮包里的文件保存後在哪裡 壓縮包里的文件保存後在哪個位置
1、如果壓縮包里的文件直接打開,那麼是會保存到C盤裡面的。如果word文件在壓縮包修改後,一般是保存在壓縮包里,但需要確認這個壓縮包是支持修改的。
2、如果壓縮包里的文件直接打開,那麼是會保存到C盤裡面的。在壓縮包里直接打開文件,系統會在C:\DocumentsandSettings\Administrator\LocalSettings\Temp\下或其下面的某個子文件夾中建立一個臨時文件,如果你直接保存的話也是將文件存到該文件夾中。你可以用搜索功能找出你保存的文件。不過,最好的保存方法是用「另存為」把文件存到指定的文件夾上,節省磁碟空間。
3、另外,word文件在壓縮包修改後,一般是保存在壓縮包里,但需要確認這個壓縮包是支持修改的,如果壓縮包是只讀的,那麼修改的WORD文檔應該在臨時文件夾中,無法更新到包內的;還有自動恢復功能可能找到,文件-選項-保存-自動恢復文件位置,點後面的瀏覽,看看有沒有。
4、Winrar默認臨時目錄\DocumentsandSettings\用戶名\LocalSettings\Temp\。不同壓縮軟體位置有一定變化,也可以在壓縮軟體設置。不過RAR文件在本地硬碟時,會直接把改過的文件再加進壓縮包,可以看看壓縮文件里編輯過的文檔是不是想要的。
⑸ 怎麼把文件夾壓縮成壓縮包
以window7為例,文件壓縮需要用戶找到需要壓縮的文件,滑鼠右鍵彈出選項,選擇添加到壓縮包,點擊後文件自動壓縮。
方法步驟如下:
1、使用網路搜索「winrar」點擊「立即下載」下載好「winrar」安裝包。
⑹ linux tar壓縮解壓縮文件夾、文件命令詳解
linux tar壓縮解壓縮文件夾、文件命令詳解
直接先上三個常用命令
1.壓縮當前目錄下文件夾/文件yk到yk.tar.gz:
2.解壓縮當前目錄下的yk.tar.gz到file:
參數詳解
五個命令中必選一個
-c: 建立壓縮檔案
-x:解壓
-t:查看內容
-r:向壓縮歸檔文件末尾追加文件
-u:更新原壓縮包中的文件
這幾個參數是可選的
-z:有gzip屬性的
-j:有bz2屬性的
-Z:有compress屬性的
-v:顯示所有過程
-O:將文件解開到標准輸出
-f必選參數
-f: 使用檔案名字,這個參數是最後一個參數,後面只能接檔案名。
查看
在不解壓的情況下查看壓縮包的內容:
⑺ C# zip 文件夾壓縮問題
string startPath = @"c:\example\start";string zipPath = @"c:\example\result.zip";string extractPath = @"c:\example\extract";ZipFile.CreateFromDirectory(startPath, zipPath);ZipFile.ExtractToDirectory(zipPath, extractPath);
⑻ 直接打開壓縮包文件會被暫時解壓到哪
01解壓到臨時文件夾C:Documents and Settings用戶名Local SettingsTempRar$xxxxxx,每次臨時解壓後,上一次臨時解壓的文件將會被刪除。
⑼ 文件夾如何壓縮
step1、滑鼠選中文件夾,單擊滑鼠右鍵,選擇【添加到壓縮文件】或者【添加到(文件夾名稱***)】
註:【添加到壓縮文件】壓縮後壓縮包保存在該文件夾當前頁面;【添加到(文件夾名稱***)】壓縮後的壓縮包保存在該文件夾內,也就是打開該文件夾才能看到壓縮包。
step2、設置壓縮包文件名和參數
壓縮包文件名可以自定義修改,如果沒有需求可以直接跳過;壓縮文件格式無需選擇,直接默認選擇;壓縮選項勾選,壓縮後是否刪除原有文件,剩餘的選擇可以直接忽略;然後點擊【確定】
step3、系統顯示壓縮進度,文件內存越大壓縮耗時越長,請耐心等待,壓縮完成。