You received SoftArtisans Archive free with your purchase of XFile. SoftArtisans Archive is a sophisticated component for the creation and extraction of Zip and Cab archives.
With SoftArtisans Archive you can,
Using Archive in conjunction with XFile, you can compress several files and upload or download the archive file. You can then use Archive to extract the uploaded files on the server, or the downloaded files on the client.
Create an HTML script, containing the following lines.
<script language="vbs">
Sub CreateArchive_OnClick()
// Set the archive format
// 1 - Zip format
// 2 - Cab format
arch.ArchiveType = 1
// Create the Zip file
arch.CreateArchive "c:\temp\ZipArch.zip"
// Add files to the Zip file
arch.AddFile "c:\report.doc"
arch.AddFile "c:\image.jpg"
arch.CloseArchive
End Sub
</script>
<Input Type=Button Name="CreateArchive" Value="Create Archive">
<Object Classid="clsid:D3400FEE-041F-11D3-B1C5-00A0C9B4587A" Codebase="localhost/SAXFileSamples/saxfile.cab"
ID="arch">
</Object>
CreateArchive_OnClick()
executes when the user clicks the "Create Archive" button.ArchiveType
property specifies whether the archive format will be Zip or Cab.
Set ArchiveType
to 1 to create a Zip file, or 2 to create a Cab file.CreateArchive
method creates a new archive file. CreateArchive
takes one parameter, the archive name.
The archive name should include both the file path and file name.AddFile
method adds a file or folder to the archive. Use AddFile afterCreateArchive
or OpenArchive
(see Programmer's Reference). AddFile
takes two parameters, the file or folder
path and name, and the optional parameter bRecursive. When bRecursive is set to True, Archive will
add any sub-directories to the archive, maintaining the original directory structure. The default value of
bRecursive is False. CloseArchive
method closes the archive. Use CloseArchive
to save any file additions or deletions.
If you do not close the archive, all changes will be lost.
<Input>
tag creates a "Create Archive" button. When the user clicks this button, the
CreateArchive_OnClick()
procedure will execute.<Object>
tag creates an instance of SoftArtisans Archive. Classid
specifies Archive's unique
class id, clsid:D3400FEE-041F-11D3-B1C5-00A0C9B4587A. Codebase
specifies the location of saxfile.cab,
which contains SAArch.dll (Archive's dll). ID
assigns a name to the created instance of SoftArtisans Archive.
Exercise 15 demonstrated creating an instance of SoftArtisans Archive on the client, using the <object>
tag. You can also use Archive on the server, within an ASP script.
To create an instance of Archive within an ASP script, use Server.CreateObject
, as follows.
Set objArchive = Server.CreateObject("Softartisans.Archive")