加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Unrar C#中的存档

发布时间:2020-12-16 02:01:37 所属栏目:百科 来源:网络整理
导读:我想静态提取.rar档案. .Net在IO.Compression中没有任何Rar类,所以我想使用cmd(它比外部dll更好).它提取,但不是静音模式.我究竟做错了什么? const string source = "D:22.rar";string destinationFolder = source.Remove(source.LastIndexOf('.'));string
我想静态提取.rar档案. .Net在IO.Compression中没有任何Rar类,所以我想使用cmd(它比外部dll更好).它提取,但不是静音模式.我究竟做错了什么?

const string source = "D:22.rar";
string destinationFolder = source.Remove(source.LastIndexOf('.'));
string arguments = string.Format(@"x -s ""{0}"" *.* ""{1}""",source,destinationFolder);
Process.Start("winrar",arguments);

解决方法

我自己使用这段代码(你的代码已添加):

const string source = "D:22.rar";
string destinationFolder = source.Remove(source.LastIndexOf('.'));
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = ""C:Program FilesWinRARwinrar.exe"";
p.StartInfo.Arguments = string.Format(@"x -s ""{0}"" *.* ""{1}""",destinationFolder);
p.Start();
p.WaitForExit();

这将在后台启动WinRAR程序,并在文件完成取消后将控制权返回给您.

希望能有所帮助

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读