ProcessStartInfo startinfo; Process process; cmd = string.Format(" a -ep -ibck -afzip {0}.zip {1}", path, rarName); startinfo = new ProcessStartInfo(); startinfo.FileName = "winrar.exe"; startinfo.Arguments = cmd; startinfo.UseShellExecute = true; startinfo.WindowStyle = ProcessWindowStyle.Hidden; process = new Process(); process.StartInfo = startinfo; process.Start(); process.WaitForExit(); if (process.HasExited) { }
Try this。Just found out from the Internet
Public Function Unrar(ByVal HttpFile As String) As String Try Dim StartInfo As ProcessStartInfo Dim Process As Process Dim r As New Random Dim UnRarPath As String = System.Web.HttpContext.Current.Server.MapPath("~/Temp/Unrar/") & r.Next Dim cmd As String = " x -p- -o+" & Space(1) & "" & HttpFile & Space(1) & "" & UnRarPath StartInfo = New ProcessStartInfo() StartInfo.FileName = "winrar.exe" StartInfo.Arguments = cmd StartInfo.UseShellExecute = True Directory.CreateDirectory(UnRarPath) StartInfo.WindowStyle = ProcessWindowStyle.Hidden Process = New Process() Process.StartInfo = StartInfo Process.Start() Process.WaitForExit() If Process.HasExited Then TraversalAllFiles(UnRarPath) End If Process.Close() Return UnRarPath Catch ex As Exception Save.Save(ex.Message) End Try Return "False" End Function Public Function TraversalAllFiles(ByVal DirPath As String) As Boolean '遍历解压缩出来的所有文件 For Each Dir As String In Directory.GetDirectories(DirPath) TraversalAllFiles(Dir) For Each File As String In Directory.GetFiles(Dir) Save.Save(File) Next Next End Function
Process process;
cmd = string.Format(" a -ep -ibck -afzip {0}.zip {1}", path, rarName);
startinfo = new ProcessStartInfo();
startinfo.FileName = "winrar.exe";
startinfo.Arguments = cmd;
startinfo.UseShellExecute = true;
startinfo.WindowStyle = ProcessWindowStyle.Hidden;
process = new Process();
process.StartInfo = startinfo;
process.Start();
process.WaitForExit();
if (process.HasExited)
{
}
Try this。Just found out from the Internet
Public Function Unrar(ByVal HttpFile As String) As String
Try
Dim StartInfo As ProcessStartInfo
Dim Process As Process
Dim r As New Random
Dim UnRarPath As String = System.Web.HttpContext.Current.Server.MapPath("~/Temp/Unrar/") & r.Next
Dim cmd As String = " x -p- -o+" & Space(1) & "" & HttpFile & Space(1) & "" & UnRarPath
StartInfo = New ProcessStartInfo()
StartInfo.FileName = "winrar.exe"
StartInfo.Arguments = cmd
StartInfo.UseShellExecute = True
Directory.CreateDirectory(UnRarPath)
StartInfo.WindowStyle = ProcessWindowStyle.Hidden
Process = New Process()
Process.StartInfo = StartInfo
Process.Start()
Process.WaitForExit()
If Process.HasExited Then
TraversalAllFiles(UnRarPath)
End If
Process.Close()
Return UnRarPath
Catch ex As Exception
Save.Save(ex.Message)
End Try
Return "False"
End Function Public Function TraversalAllFiles(ByVal DirPath As String) As Boolean
'遍历解压缩出来的所有文件
For Each Dir As String In Directory.GetDirectories(DirPath)
TraversalAllFiles(Dir)
For Each File As String In Directory.GetFiles(Dir)
Save.Save(File)
Next
Next End Function