惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Last Watchdog
The Last Watchdog
博客园_首页
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
美团技术团队
小众软件
小众软件
V
V2EX
博客园 - Franky
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
Attack and Defense Labs
Attack and Defense Labs
S
Security Affairs
Simon Willison's Weblog
Simon Willison's Weblog
I
Intezer
T
The Exploit Database - CXSecurity.com
有赞技术团队
有赞技术团队
S
Schneier on Security
人人都是产品经理
人人都是产品经理
Security Archives - TechRepublic
Security Archives - TechRepublic
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
K
Kaspersky official blog
PCI Perspectives
PCI Perspectives
AI
AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
罗磊的独立博客
O
OpenAI News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The Register - Security
The Register - Security
V
Vulnerabilities – Threatpost
GbyAI
GbyAI
博客园 - 【当耐特】
C
Cisco Blogs
大猫的无限游戏
大猫的无限游戏
Help Net Security
Help Net Security
Google DeepMind News
Google DeepMind News
S
Securelist
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Proofpoint News Feed
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
L
LangChain Blog
SecWiki News
SecWiki News
博客园 - 叶小钗
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V2EX - 技术
V2EX - 技术
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
L
LINUX DO - 热门话题
Cisco Talos Blog
Cisco Talos Blog

博客园 - 朱胜

exeCommand 阻止浏览器事件传递 Ext js Grouping 展开和折叠方法 JS获取上传文件的绝对路径,兼容IE和FF - 朱胜 - 博客园 asp.net2.0中异步调用WebService - 朱胜 - 博客园 ASP.Net的正则表达式(RegularExpression) Extjs简介(二) Extjs框架简介(一) ASP.NET 恢复备份Sql server - 朱胜 WPF学习2:布局(上) WPF学习笔记1 WPF生命周期和参数配置 WPF编程笔记 0:WPF概况(上部分) JavaScript判断文件大小 - 朱胜 - 博客园 clientHeight,offsetHeight和scrollHeight区别 CSS HACK(ie6-ie7-fox 兼容) 页面禁止后退的方法 upLoad控件设置禁止输入的方法 - 朱胜 - 博客园 [ASP.NET] 实现Label自动换行 - 朱胜 - 博客园 js调用web服务范例 - 朱胜 - 博客园
ASP.NET 压缩和解压缩 - 朱胜 - 博客园
朱胜 · 2010-04-25 · via 博客园 - 朱胜


        /// <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    " + " " + DRARName + "  " + DFilePath; //命令 + 压缩后文件名 + 被压缩的文件或者路径
                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)
            {
                Response.Write(ex.Message);
                return false;
            }
        }

        /// <summary>
        /// 解压缩到指定文件夹
        /// </summary>
        /// <param name="RARFilePath">压缩文件存在的目录 </param>
        /// <param name="RARFileName">压缩文件名称 </param>
        /// <param name="UnRARFilePath">解压到文件夹</param>
        /// <returns></returns>
        protected bool UnRAR(string RARFilePath, string RARFileName, string UnRARFilePath)
        {
            //解压缩
            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 = @" X " + " " + RARFilePath + RARFileName + " " + UnRARFilePath;
                the_StartInfo = new ProcessStartInfo();
                the_StartInfo.FileName = the_rar;
                the_StartInfo.Arguments = the_Info;
                the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                the_Process = new Process();
                the_Process.StartInfo = the_StartInfo;
                the_Process.Start();
                return true;
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
                return false;
            }
        }