using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using FreshpowerWeb.function;
using PowerNetManagerSystem.Model;

using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Diagnostics;


using System.IO;
using System.Diagnostics;
using System.ComponentModel;

using System.Web.Security;
using System.Web.SessionState;


public partial class Bidder_Test : System.Web.UI.Page
{
    private PowerNetManagerSystem.BLL.HALL_PRODUCT_BLL prodCateBLL = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            MB_T_HALL_PRODUCT_Info info = new MB_T_HALL_PRODUCT_Info();
            prodCateBLL = new PowerNetManagerSystem.BLL.HALL_PRODUCT_BLL();
            info.BIDDER_NO = "B84734";

            DataSet ds = new DataSet();
            ds=prodCateBLL.GetCompanyList(info);
        }
       // GetCompanyInfo
    }

    /// <summary>
    /// 解压缩
    /// </summary>
    protected void Button1_Click(object sender, EventArgs e)
    {
    
         string rar;
         RegistryKey reg;
         string args;
         ProcessStartInfo startInfo;
         Process process;
         try
         {
              reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRar.exe\Shell\Open\Command");
              rar = reg.GetValue("").ToString();
              reg.Close();
              rar = rar.Substring(1, rar.Length - 7);
              args = @" X C:\\Test\hello.rar C:\\Test";
              startInfo = new ProcessStartInfo();
              startInfo.FileName = rar;
              startInfo.Arguments = args;
              startInfo.WindowStyle = ProcessWindowStyle.Hidden;
              process = new Process();
              process.StartInfo = startInfo;
              process.Start();
              Response.Write("<script>alert('解压成功')</script>");
         }
         catch (Exception ex)
         {
            Response.Write(ex.ToString());
         }


    }

//    例:把E:\web\目录下的所有东西打包为1.rar放到E:\web\目录下,以便下载
//"C:\Program Files\WinRAR\Rar.exe" a -k -r -s -m1 E:\web\1.rar E:\web\
//参数说明:
//a 添加文件到压缩文件中
//-k 锁定压缩文件
//-s产生固体存档,这样可以增大压缩比
//-r包括子目录
//-m1 设置压缩比
//   -m0   存储      添加到压缩文件时不压缩文件。
//   -m1   最快      使用最快方式(低压缩)
//   -m2   较快      使用快速压缩方式
//   -m3   标准      使用标准(默认)压缩方式
//   -m4   较好      使用较好压缩方式(较好压缩,但是慢)
//   -m5   最好      使用最大压缩方式(最好的压缩,但是最慢)


    /// <summary>
    /// 压缩
    /// </summary>
    protected void Button2_Click(object sender, EventArgs e)
    {
         string rar;
         RegistryKey reg;
         string args;
         ProcessStartInfo procStart;
         Process process;
         try
         {
              reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command");
              rar = reg.GetValue("").ToString();//获取注册表rar安装路径
              reg.Close();
              rar = rar.Substring(1, rar.Length - 7);//获取rar安装路径
              args = @"a -inul -y C:\\Test\temp.rar C:\\Test\1.txt";//这里为rar的压缩命令格式(也可以自行扩展)
              procStart = new ProcessStartInfo();
              procStart.FileName = rar;
              procStart.Arguments = args;//参数
              procStart.WindowStyle = ProcessWindowStyle.Hidden;//窗口状态
              procStart.WorkingDirectory = Server.MapPath(""); ;//获取或设置要启动的进程的初始目录。
              process = new Process();
              process.StartInfo = procStart;
              process.Start();
              Response.Write("<script>alert('压缩成功')</script>");
         }
         catch (Exception ex)
         {
          Response.Write(ex.ToString());
         }


    }

}

 

posted on 2010-10-15 15:45  poop  阅读(220)  评论(0编辑  收藏  举报