从ASP页面使用7-Zip压缩文件夹 [英] Zipping a folder using 7-Zip from an asp page
本文介绍了从ASP页面使用7-Zip压缩文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从ASP页面压缩文件夹。这是我的代码:
I am trying to zip a folder from an asp page. This is my code:
zipFolderName=folderName &"Zipped.zip"
command="cd C:\Program Files\7-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 $ c中编写的命令$ c>是
cd C:\Program Files\7-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.
我在做什么错?
推荐答案
您需要放入 C:\Program Files\7-Zip
用双引号引起来,因为路径包含空格。另外, cd
和&
是CMD内置的,因此您需要在<$ c $中运行命令行c> CMD 。
You need to put C:\Program Files\7-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 Files\7-Zip & "
command = "%COMSPEC% /c cd ""C:\Program Files\7-Zip"" & "
这篇关于从ASP页面使用7-Zip压缩文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文