从 Web 应用程序启动流程

发布于 2024-07-10 09:10:40 字数 973 浏览 6 评论 0原文

我实际上正在尝试启动 winzip 和压缩文件夹的过程。 我正在使用以下 vb 代码执行此操作。

Dim startInfo As New System.Diagnostics.ProcessStartInfo
Dim pStart As New System.Diagnostics.Process
Dim tempFileName As String
Try
    startInfo = New System.Diagnostics.ProcessStartInfo( _
    "c:\Program Files\WinZip\WINZIP32.EXE")
    startInfo.Arguments = " -a -r ""c:\test.zip"" c:\test"
    startInfo.UseShellExecute = False
    startInfo.WindowStyle = Diagnostics.ProcessWindowStyle.Normal

    pStart.StartInfo = startInfo
    'startInfo.WorkingDirectory = "c:\Program Files\WinZip"
    'startInfo.FileName = "WINZIP32.EXE"
    pStart.Start()
    pStart.WaitForExit()
    
Catch ex As Exception
    Throw
End Try

当将其放入 Windows 应用程序的按钮单击事件中时,效果很好。 但是,当在 Web 应用程序的按钮单击事件中执行相同操作时,我可以看到该进程在计算机的任务管理器中启动。 但它不会压缩,也不会关闭应用程序,也不会弹出 winzip ui....但在极少数机器上,这确实工作正常。 在大多数机器上,我都面临着这个问题,并且也能够一致地重现该问题...

但是,如果我尝试使用 7z zip 做类似的事情,它确实可以很好地形成 Web 应用程序本身...

是否有解决方法这个流程?

I am actually trying to start a process for winzip and zip a folder. This i am doing using the below code in vb.

Dim startInfo As New System.Diagnostics.ProcessStartInfo
Dim pStart As New System.Diagnostics.Process
Dim tempFileName As String
Try
    startInfo = New System.Diagnostics.ProcessStartInfo( _
    "c:\Program Files\WinZip\WINZIP32.EXE")
    startInfo.Arguments = " -a -r ""c:\test.zip"" c:\test"
    startInfo.UseShellExecute = False
    startInfo.WindowStyle = Diagnostics.ProcessWindowStyle.Normal

    pStart.StartInfo = startInfo
    'startInfo.WorkingDirectory = "c:\Program Files\WinZip"
    'startInfo.FileName = "WINZIP32.EXE"
    pStart.Start()
    pStart.WaitForExit()
    
Catch ex As Exception
    Throw
End Try

This works fine when it's put in a button click event of a windows application. But when the same is done in a button click event of a web application I can see the process is started in the task manager of the machine. But its doesn't zip nor does it close the application nor does it pop up its winzip ui.... But in very few machines this does work fine. In most of the machine i am facing the problem and also able to reproduce the problem consistently...

But a similar thing if i try doing using 7z zip, it does work fine form a web application itself...

Is there a workaround for this process?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

晨曦慕雪 2024-07-17 09:10:40

我相信 .Net 框架具有内置的 zip 功能。 我会先尝试使用这些。 由于 Web 服务器上的权限问题,您的 zip 程序可能未运行。

编辑

我刚刚检查过,System.IO.Compression 中的 zip 支持似乎有限。 但根据 此讨论,这可能不是您需要的。 然而,该讨论提到了一篇名为“Decompress Zip files with Windows Shell API 的文章和 C#”。

I believe that the .Net framework has built in zip capabilities. I would try using those first. Your zip program probably isn't running because of permissions on the web server.

Edit

I just checked and there seems to be limited zip support in System.IO.Compression. But according to this discussion, it might not be what you need. That discussion however, mentions an article called "Decompress Zip files with Windows Shell API and C#".

能怎样 2024-07-17 09:10:40

这可能与 IIS 运行的用户有关; 尝试更改应用程序池以在您的身份中运行,看看它是否有效。 当然,winzip 是一个 UI 工具 - 您可能使用命令行 zip 实用程序会做得更好... pkzip ;-p

就个人而言,我会考虑使用 #ZipLib 相反 - 这将允许您在托管代码中操作 zip 文件。

It might be something to do with the user that IIS is running as; try changing the app-pool to run in your identity to see if it works. Of course, winzip is a UI tool - you might do better using a command-line zip utility... pkzip ;-p

Personally, I'd look at using #ZipLib instead - this will allow you to manipulate zip files in managed code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文