首页 > Linux操作系统 > Linux操作系统 > 用C#实现RAR文件的自动解压缩
Process p = new Process();
// 需要启动的程序名
p.StartInfo.FileName = winrarExe ;
// 参数
string arguments = @"x -inul -y -o+";
arguments += " " + rarFileToDecompress + " " + directoryToSave;
p.StartInfo.Arguments = arguments;
p.Start();//启动
while(!p.HasExited)
{
}
p.WaitForExit();
}
catch(Exception ee)
{
throw new Exception("上传的压缩文件在解压缩的过程中出现了错误!
请联系管理员检查您是否有对相应目录的写入权限!");
}
if (deleteRarFile)
{
File.Delete(rarFileToDecompress);
}
}
else
{
throw new Exception("系统服务器上缺少必须的Winrar.exe文件,不能完成相应操作请联系管理员!");
}
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12639172/viewspace-442009/ ,如需转载,请注明出处,否则将追究法律责任。