使用 7-Zip 从 asp 页面压缩文件夹 [英] Zipping a folder using 7-Zip from an asp page

查看:46
本文介绍了使用 7-Zip 从 asp 页面压缩文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 asp 页面压缩文件夹.这是我的代码:

I am trying to zip a folder from an asp page. This is my code:

zipFolderName=folderName &"Zipped.zip"
command="cd C:Program Files7-Zip & "
command = command & "7z a -tzip " & zipFolderName & " """ & folderName & """"
Response.Write command

set objshell = Server.CreateObject("WScript.shell")
objShell.exec (command)
set objshell=nothing

写在Response.Write中的命令是

cd C:Program Files7-Zip & 7z a -tzip D:/saveAll/DocumentsZipped.zip "D:/saveAll/Documents" 

当我在 cmd 窗口中运行此命令时,它工作得很好.但是我的asp页面显示错误:

When I run this command in a cmd window it works just fine. But my asp page shows an error:

WshShell.Exec error '80070002' 

系统找不到指定的文件.

The system cannot find the file specified.

错误出在 objShell.exe 命令行上.

The error is on the objShell.exe command-line.

我做错了什么?请帮忙!

What am I doing wrong? Please help!

推荐答案

您需要将 C:Program Files7-Zip 放在双引号之间,因为路径中包含空格.另外,cd& 是 CMD 内置的,所以你需要在 CMD 中运行命令行.

You need to put C:Program Files7-Zip between double quotes, because the path contains a space. Also, cd and & are CMD-builtins, so you need to run the command line in CMD.

改变这个:

command="cd C:Program Files7-Zip & "

进入这个:

command = "%COMSPEC% /c cd ""C:Program Files7-Zip"" & "

这篇关于使用 7-Zip 从 asp 页面压缩文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆