/// <summary>
/// 解压缩文件
/// </summary>
/// <param name="stylepath">压缩文件路径</param>
private void unzipFile(string stylepath)
{
String Rar;
RegistryKey Reg;
Object Obj;
String Info;
ProcessStartInfo StartInfo;
Process Process;
try
{
Reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRar.exe\Shell\Open\Command");
Obj = Reg.GetValue("");
Rar = Obj.ToString();
Reg.Close();
Rar = Rar.Substring(1, Rar.Length - 7);
string targetdir = Path.GetDirectoryName(stylepath) + "\\" + Path.GetFileNameWithoutExtension(stylepath);
if (!Directory.Exists(targetdir))
{
Directory.CreateDirectory(targetdir);
}
Info = " X " + stylepath + " " + targetdir;
StartInfo = new ProcessStartInfo();
StartInfo.FileName = Rar;
StartInfo.Arguments = Info;
StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process = new Process();
Process.StartInfo = StartInfo;
Process.Start();
//判断解压缩文件的进程是否结束
while (true)
{
if (Process.HasExited == true)
break;
else
System.Threading.Thread.Sleep(1000);
}
}
catch (Exception ex)
{
this.ltlinformation.Text = "文件上传失败:" + ex.ToString();
}
finally
{
GC.Collect();
GC.Collect(1);
}
}
/// 解压缩文件
/// </summary>
/// <param name="stylepath">压缩文件路径</param>
private void unzipFile(string stylepath)
{
String Rar;
RegistryKey Reg;
Object Obj;
String Info;
ProcessStartInfo StartInfo;
Process Process;
try
{
Reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRar.exe\Shell\Open\Command");
Obj = Reg.GetValue("");
Rar = Obj.ToString();
Reg.Close();
Rar = Rar.Substring(1, Rar.Length - 7);
string targetdir = Path.GetDirectoryName(stylepath) + "\\" + Path.GetFileNameWithoutExtension(stylepath);
if (!Directory.Exists(targetdir))
{
Directory.CreateDirectory(targetdir);
}
Info = " X " + stylepath + " " + targetdir;
StartInfo = new ProcessStartInfo();
StartInfo.FileName = Rar;
StartInfo.Arguments = Info;
StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process = new Process();
Process.StartInfo = StartInfo;
Process.Start();
//判断解压缩文件的进程是否结束
while (true)
{
if (Process.HasExited == true)
break;
else
System.Threading.Thread.Sleep(1000);
}
}
catch (Exception ex)
{
this.ltlinformation.Text = "文件上传失败:" + ex.ToString();
}
finally
{
GC.Collect();
GC.Collect(1);
}
}