首页 新闻 赞助 找找看

asp.net压缩文件问题

0
悬赏园豆:5 [已关闭问题]

我用ASP.net写了一个压缩文件的代码,在XP下可以压缩成功,但在windows2003下VS默认服务下可以压缩成功,但放在IIS下就报错了,IIS下的权限是administr最高权限了

System.ComponentModel.Win32Exception: 系统找不到指定的文件。 在 System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) 在 System.Diagnostics.Process.Start() 在 manage_Default3.Button1_Click(Object sender, EventArgs e) 位置 e:\dress.com\manage\Default3.aspx.cs:行号 45

压缩代码:

String the_rar;
        RegistryKey the_Reg;
        Object the_Obj;
        String the_Info;
        ProcessStartInfo the_StartInfo;
        Process the_Process;
        try
        {
            the_Reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command");
            the_Obj = the_Reg.GetValue("");
            the_rar = the_Obj.ToString();
            the_Reg.Close();
            the_rar = the_rar.Substring(1, the_rar.Length - 7);
            the_Info = " a    " + @"e:\jquery\1.rar " + "  " + @"F:\网站资料\01.jpg " + @"F:\网站资料\02.jpg";
            the_StartInfo = new ProcessStartInfo();
            the_StartInfo.FileName = the_rar;
            the_StartInfo.Arguments = the_Info;
            the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            the_StartInfo.WorkingDirectory = @"e:\jquery\1";//获取或设置要启动的进程的初始目录。
            the_Process = new Process();
            the_Process.StartInfo = the_StartInfo;
            the_Process.Start();
            Response.Write("压缩成功");
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }

hebeiping的主页 hebeiping | 初学一级 | 园豆:110
提问于:2010-01-12 00:02
< >
分享
其他回答(1)
0
代码
string strRarFileName = strNow + ".rar";
string strTarget = strDirPath + "\\" + strRarFileName;

string strShellCommand = String.Concat("a -p", DateTime.Now.Day + strPassword + "qpcard", " ", strTarget, " ", strFileName);
System.Environment.CurrentDirectory
= strDirPath;
System.Diagnostics.Process proRar
= new System.Diagnostics.Process();
proRar.StartInfo.FileName
=Path.Combine(strDirPath,strRarFileExe) ;
proRar.StartInfo.Arguments
= strShellCommand;
proRar.StartInfo.WindowStyle
= System.Diagnostics.ProcessWindowStyle.Hidden;
try
{
proRar.Start();

}
catch (Exception)
{
return "";
}

 

这个是通过调用Winrar来压缩文件的。

 

你这个应该是找不到压缩程序的路径,试试把程序分别放在网站或虚拟目录里。

或者输出路径再看下吧

齐.net | 园豆:1421 (小虾三级) | 2010-01-12 09:18
已经解决,是在windows2003服务器下没有winrar权限的问题,添加权限就OK了
支持(0) 反对(0) hebeiping | 园豆:110 (初学一级) | 2010-01-12 13:47
0

何必这么复杂!!!,直接调用压缩类!!!

请参照http://www.51aspx.com/CV/zxjayWebExplorer/

这里面有个,你直接抠下来用就是了。。。。

ForFreeDom | 园豆:589 (小虾三级) | 2010-01-12 13:12
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册