Adds the specified local file to the archive.
object.PutFile ( LocalFile, ZipFile ) |
- LocalFile
- Required. A String that represents the full path of the file on the local device.
- ZipFile
- Required. A String that represents the name of the file inside the archive.
Boolean
PutFile Example
Adds a file to a ZIP Archive.
PutFile Example (VBScript) | Copy Code |
---|---|
Sub PutFile(strArchiveFile, strPassword, strSourceFile, strCompressedFile) ' Open the ZIP archive Dim pArchive Set pArchive = Application.CreateAppObject("Archive") If (Not pArchive.Open(strArchiveFile)) Then Exit Sub pArchive.Password = strPassword ' NOTE: Alternatively, password can be supplied as an argument to the Open method ' Insert a file into the ZIP archive. Dim blnResult blnResult = pArchive.PutFile(strSourceFile, strCompressedFile) ' Close the ZIP archive pArchive.Close() ' Display the results If (Not blnResult) Then Application.MessageBox "Failed to add file.", vbCritical, "Error" Else Application.MessageBox strSourceFile & " added as " & strCompressedFile, vbInformation, "Success" End If End Sub |