压缩文件夹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、系统显示压缩进度,文件内存越大压缩耗时越长,请耐心等待,压缩完成。