zoukankan      html  css  js  c++  java
  • ASP.NET利用WINRar实现在线解压缩文件

    一、肯定是服务器必须装了winrar这个软件了。

    二、创建Helper类,如下:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Win32;
    using System.Diagnostics;
    using System.IO;
    
    namespace XXX.Common
    {
    
        public class ZipHelper
        {
            public bool DeCompressRAR(string sourceFilePath, string destinationPath)
            {
                try
                {
                    string SeverDir = @"C:Program FilesWinRAR";//rar.exe的要目录 
                    Process ProcessDecompression = new Process();
                    ProcessDecompression.StartInfo.FileName = SeverDir + "\rar.exe";
                    Directory.CreateDirectory(destinationPath);
                    ProcessDecompression.StartInfo.Arguments = " X " + sourceFilePath + " " + destinationPath;
                    ProcessDecompression.Start();
                    while (!ProcessDecompression.HasExited)
                    {
                        //nothing to do here. 
                    }
                    return true;
                }
                catch (System.Exception)
                {
                    return false;
                }
            } 
        }
    }

    三、直接调用就可以了,如下:

            public ActionResult jieya()
            {
                Common.ZipHelper zipHelper = new Common.ZipHelper();
                zipHelper.DeCompressRAR(@"d:210.rar", @"d:a");
                return Json(message, JsonRequestBehavior.AllowGet);
            }
  • 相关阅读:
    three.js详解
    Javascript的原型
    Transform? Transition? Animation?
    Backbone源码分析Backbone架构+流程图
    对象是引用的注意原型中的属性改变
    MySQL+ JSP+Tomcat開發指引
    MySQL應用分析
    SQL 日期
    MySQL安裝
    MSE错误应对分享
  • 原文地址:https://www.cnblogs.com/subendong/p/3715395.html
Copyright © 2011-2022 走看看