我想把 E:\\AA\BB\11.txt 压缩后存入 E:\\AA1\BB1\11.rar

但是当我解压( E:\\AA1\BB1\11.rar)的时候,发现:11.txt 不是在

E:\\AA1\BB1\11.txt 路径下,

而是

E:\\AA1\BB1\AA\BB\11.txt

悲剧就这样进行着,

下面是我的解决方案:

 /// <summary>
/// 压缩文件
/// </summary>
/// <param name="DFilePath">需要压缩的文件夹或者单个文件</param>
/// <param name="DRARName">生成压缩文件的文件名</param>
/// <param name="DRARPath">生成压缩文件保存路径</param>
/// <returns></returns>
protected bool RAR(string DFilePath, string DRARName, string DRARPath)
{
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 -r " + DRARName + " " + DFilePath;
the_Info = " a -ep " + DRARName + " " + DFilePath;//这句话的 ‘-ep’很重要,有它就能不显示压缩前的路径
the_StartInfo = new ProcessStartInfo();
the_StartInfo.FileName = the_rar;
the_StartInfo.Arguments = the_Info;
the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
the_StartInfo.WorkingDirectory = DRARPath; //RaR文件的存放目录。
the_Process = new Process();
the_Process.StartInfo = the_StartInfo;
the_Process.Start();
return true;
}
catch (Exception ex)
{
return false;
}
}

C#压缩文件 不压缩路径的更多相关文章

  1. Java学习笔记之I/O流(读取压缩文件以及压缩文件)

    1.读取压缩文件:ZipInputStream 借助ZipFile类的getInputStream方法得到压缩文件的指定项的内容,然后传递给InputStreamReader类的构造方法,返回给Buf ...

  2. C#压缩文件,C#压缩文件夹,C#获取文件

    using System; using System.Data; using System.Configuration; using System.Collections.Generic; using ...

  3. python 压缩文件(解决压缩路径问题)

    #压缩文件 def Zip_files(): datapath = filepath # 证据路径 file_newname = datapath + '.zip' # 压缩文件的名字 log.deb ...

  4. 《Java知识应用》Java压缩文件和解压缩

    今天通过Java实现一下:文件的压缩和解压缩. 1. 压缩 准备文件: 准备代码:(压缩) import java.io.BufferedInputStream; import java.io.Buf ...

  5. linux 压缩文件 及压缩选项详解

    本文介绍linux下的压缩程序tar.gzip.gunzip.bzip2.bunzip2.compress.uncompress. zip. unzip.rar.unrar等程式,以及如何使用它们对. ...

  6. linux下tar gz bz2 tgz z等众多压缩文件的压缩与解压方法

    Linux下最常用的打包程序就是tar了,使用tar程序打出来的包我们常称为tar包,tar包文件的命令通常都是以.tar结尾的.生成tar包后,就可以用其它的程序来进 行压缩了,所以首先就来讲讲ta ...

  7. 71. Simplify Path压缩文件的绝对路径

    [抄题]: Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/&q ...

  8. 【C#公共帮助类】WinRarHelper帮助类,实现文件或文件夹压缩和解压,实战干货

    关于本文档的说明 本文档使用WinRAR方式来进行简单的压缩和解压动作,纯干货,实际项目这种压缩方式用的少一点,一般我会使用第三方的压缩dll来实现,就如同我上一个压缩类博客,压缩的是zip文件htt ...

  9. Linux常用命令学习3---(文件的压缩和解压缩命令zip unzip tar、关机和重启命令shutdown reboot……)

    1.压缩和解压缩命令    常用压缩格式:.zip..gz..bz2..tar.gz..tar.bz2..rar .zip格式压缩和解压缩命令        zip 压缩文件名 源文件:压缩文件   ...

随机推荐

  1. [ActionScript 3.0] 喷泉效果

    pall为水珠影片剪辑 var count:int = 500; var zl:Number = 0.5; var balls:Array; balls = new Array(); for (var ...

  2. yum install nginx

    先安装nginx的yum源 http://nginx.org/en/linux_packages.html#stable 找到链接,安装: rpm -ivh http://nginx.org/pack ...

  3. Embed dll Files Within an exe (C# WinForms)—Winform 集成零散dll进exe的方法

    A while back I was working on a small C# WinForms application in Visual Studio 2008. For the sake of ...

  4. AX2012 常用表关系(客户地址,联系信息)

    //客户地址信息 static void CustAddressInformation(Args _args) { CustTable custTable; DirPartyTable dirPart ...

  5. Discuz开源论坛本地部署自动生成数据库

    这个版本可能比较有点老,但是万变不离其宗,再新的版本都是在已有的基础上更新的,所以掌握方法是最重要的! 先上几张安装成功后的图 (安装成功的论坛首页) (后台管理登录页) 下面说一下安装步骤 第一步: ...

  6. Loadrunner:LR提交JSON格式的POST请求

    场景: 影视分发:影院客户端向管理平台发起取任务的操作,取任务接口getDispatchTask,为JSON格式的POST请求 Action() { web_custom_request(" ...

  7. Linux 命令 ls -l

    一.ll命令 ll并不是linux下一个基本的命令,它实际上是ls -l的一个别名. Ubuntu默认不支持命令ll,必须用 ls -l,这样使用起来不是很方便. 如果要使用此命令,可以作如下修改:打 ...

  8. 转:RealThinClient (RTC)是什么?

    RealThinClient SDK是用于开发标准的HTTP(S)服务器,ISAPI扩展以及客户端的VCL控件.可用于Windows下的CodeGear Delphi 6-XE5. 功能描述 Abou ...

  9. apache-jmeter学习文档

    http://www.cnblogs.com/TankXiao/p/4045439.html#sampler

  10. MongoEngine简易教程(转)

    原文:http://www.xefan.com/archives/84063.html Mongoengine教程(1)——概述 Mongoengine教程(2)——文档模式 Mongoengine教 ...