using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace HistoryWinRar
{
public partial class formFile : Form
{
public formFile()
{
InitializeComponent();
}
private void btnUprar_Click(object sender, EventArgs e)
{
if (openFile.ShowDialog() == DialogResult.OK)
{
this.txtFile.Text = openFile.FileName;
}
}
private void btnWinrar_Click(object sender, EventArgs e)
{
string fileName = openFile.FileName;
string filePath = this.txtPath.Text;
Process cmdProcess = null;
Process unzipProcess = null;
try
{
cmdProcess = new Process();
cmdProcess.StartInfo.UseShellExecute = false;
cmdProcess.StartInfo.RedirectStandardInput = true;
cmdProcess.StartInfo.RedirectStandardOutput = true;
cmdProcess.StartInfo.RedirectStandardError = true;
cmdProcess.StartInfo.CreateNoWindow = true;
cmdProcess.StartInfo.FileName = "cmd.exe";
cmdProcess.Close();
cmdProcess.Dispose();
cmdProcess = null;
unzipProcess = new Process();
unzipProcess.StartInfo.FileName = "e:/WinRAR/WinRAR.exe";
unzipProcess.StartInfo.Arguments = " x -inul -y " + fileName + " " + filePath;//解压的文件和解压到的地方
;
unzipProcess.Start();
while (!unzipProcess.HasExited)
{
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
unzipProcess.Close();
unzipProcess.Dispose();
unzipProcess = null;
}
}
}
}