First, the question is proposed
With the development of the interconnect, the number of websites increases in an amazing number. In addition to providing information services to the majority of netizens, they should also become a place to upload and download files. In the process of uploading and downloading, the transfer time is the key, which requires a faster transfer speed. In the case where the transmission speed is fixed or the upper and lower changes, the volume of the transfer file is minimized, it is a feasible approach: When the file is uploaded, the file to be uploaded will be compressed with WinRAR. After the upload is successful, after the upload is successful, in the website Replenishment by the program; when downloading the file, the file to be downloaded will be compressed by the program in the website and then download. This article discusses the solution to this problem. Second, the method and instructions First, to upload a WinRAR decompression program, WinRAR's own decompression program, only the core program rar.exe can be found, can be found in the WinRAR installation directory. Then you have to upload a program cmd.exe that performs RAR.exe is the program in the Windows operating system, which can be found in the system disk WinNT / System32 folder. After the two files are uploaded, you need to write some program code to implement compression and decompression. The file that implements the compression function is named Zip.asp, and the file that unzipped function is named unzip.asp. The program code contains the command line syntax of the WinRAR application. Let's take a brief introduction: WinRAR
a Add files to compressed files
c Add compressed file annotation
d Delete files from the compressed file
e decompress compression from the compressed file, ignore the path
f refreshes the file in the compressed file
i Look for strings in a compressed file
K lock compressed files
m Move files and folders to compressed files
r Refract damaged compressed files
RC reconstruction of lost volumes
RN rename compressed file
RR [N] Add Data Recovery Record
RV [N] Create a recovery volume
S [Name] conversion compressed file becomes self-extracting file type
S-Delete Self-extracting module
t test compressed file
u Update the file from the compressed file
X Decompression compression from the compressed file with the full path name
The key to the program code is to use server.createObject ("wscript.shell") to perform cmd.exe, cmd.exe running Rar.exe to perform unzip files and compressed files through WinRAR commands. Third, the program list zip.asp program list:
<% 'main folder contains cmd.exe rar.exe, for example, to compress file (* .mdb)' compressed storage directory is Main / Data.raron error resume nextunzip_path = server.mappath ("main") & "/" Set wshshell = server.createObject ("wscript.shell") Issuccess = wshshell.run ("WinRAR A" & Unzip_path & "Data" & unzip_path & "*. MDB", 1, false 'WinRAR error Number: "& Err.NumberResponse.write" Reason: " & Err.DescriptionResponse.write " Error Source:" & Err.SourceResponse.write End IF%> Unzip.asp Program List: <% 'main folder contains cmd.exe rar.exe to decompress file (* .rar)' Decompressed storage directory is Mainon Error Resume NextUnzip_path = server.mappath ("main") & "/" SET Wshshell = server.createObject ("wscript.shell") Issuccess = wshshell.run ("WinRAR X -R -O " & unzip_path & "*. RAR" & unzip_path & ", 1, false) 'WinRar error number: "& err.NumberResponse.write" reason: "& Err.DescriptionResponse.write" Error Source: " & Err.SourceResponse.write End IF%> Four, conclusions This article uses RAR.exe and cmd.exe two files to implement online compression and unzipped websites in the ASP program. The implementation method is simple, the program code is small, and it can be used for practical programming. Especially in the case of your own server, it is extremely practical and convenient. The above programs are passed in Windows 200Sever and IIS5.0. TRACKBACK: http://tb.blog.9cbs.net/trackback.aspx?postid=797249