首页 新闻 会员 周边

c#压缩文件

0
悬赏园豆:10 [待解决问题]

网上找的代码片段,本地运行正常,发布后路径也更改  但是下载下来的TZ.rar一直都是 20字节,是什么原因呢?

/// <summary>  
        /// 压缩文件
        /// </summary>
        /// <returns>返回压缩后的路径</returns>
        public string YaSuo(out bool bo, out TimeSpan times)
        {
            string rarurlPath = string.Empty;
            bo = false;
            //压缩文件
            string yasuoPathSave = "c:\\de\\TZ.rar";
            string yasuoPath = "c:\\de\\temp";
            System.Diagnostics.Process pro = new System.Diagnostics.Process();
            pro.StartInfo.FileName = @"C:\Program Files\WinRAR\WinRAR.exe";//WinRAR所在路径
            //pro.StartInfo.Arguments = "a " + yasuoPathSave + " " + yasuoPath + " -r ";//dir是你的目录名
            pro.StartInfo.Arguments = string.Format("a {0} {1} -r",yasuoPathSave,yasuoPath);
 
            pro.Start();
            times = pro.TotalProcessorTime;
            bo = pro.WaitForExit(60000);//设定一分钟
            if (!bo)
                pro.Kill();
            pro.Close();
            pro.Dispose();
            rarurlPath = yasuoPathSave;
            return rarurlPath;
        }

learningcom的主页 learningcom | 初学一级 | 园豆:148
提问于:2014-03-21 16:36
< >
分享
所有回答(4)
0

你直接在 TZ.rar 上点鼠标右键,然后选择解压缩到...,你看解压缩出来是多大。另外,解压缩跟下载有什么关系吗?

Launcher | 园豆:45045 (高人七级) | 2014-03-21 16:41
0

看一下权限问题

lucika.zh | 园豆:62 (初学一级) | 2014-03-21 17:25
0
happydaily | 园豆:301 (菜鸟二级) | 2014-03-21 18:25

好的 谢谢

支持(0) 反对(0) learningcom | 园豆:148 (初学一级) | 2014-03-25 08:47
0

你这个代码依赖WinRAR这个软件。建议采用第三方的压缩类库,如SharpZipLib,再给你一个参考地址:http://www.cnblogs.com/tuyile006/archive/2008/04/25/1170894.html

如果是.Net Framework 4.5,那么自带有一个压缩库。

幻天芒 | 园豆:37175 (高人七级) | 2014-03-22 22:10

好的 谢谢

支持(0) 反对(0) learningcom | 园豆:148 (初学一级) | 2014-03-25 08:46
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册