Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Classic ASP Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Cert Store
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

Access Denied when Writing Zip

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

I get an "Access is Denied" error when writing a .zip in ASP.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
set zip = Server.CreateObject("Chilkat_9_5_0.Zip")

'  Any string unlocks the component for the 1st 30-days.
success = zip.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
    Response.Write Server.HtmlEncode(zip.LastErrorText) & "<br>"

End If

success = zip.NewZip("test.zip")
If (success <> 1) Then
    Response.Write Server.HtmlEncode(zip.LastErrorText) & "<br>"

End If

'  When a zip is written, the Chilkat Zip component will
'  write it to a temp file first.  If the entire zip is
'  successfully written, then it is moved to it's target filename,
'  possibly overwriting an existing file if a .zip having the
'  same name already exists.
'  The zip.TempDir property indicates the directory where
'  the temp zip is written.  TempDir defaults to ".", which is
'  the current working directory.

'  Append a directory tree.
recurse = 1
zip.AppendFiles "c:/inetpub/wwwroot/data/*",recurse

'  This will most certainly fail.  See below for the contents
'  of LastErrorText and the explanation.
success = zip.WriteZipAndClose()
If (success <> 1) Then
    Response.Write Server.HtmlEncode(zip.LastErrorText) & "<br>"
Else
    Response.Write Server.HtmlEncode("Zip Created!") & "<br>"
End If

'  The LastErrorText looks something like this:
'   WriteZipAndClose:
'     DllDate: Sep  7 2007
'     Username: IUSR_CHILKAT
'     Component: ActiveX
'     tempFile: .\ckz_1KTC.tmp
'     loggedOnUser: IUSR_CHILKAT
'     curDir: C:\WINDOWS\system32
'     Failed to open file (2)
'     ansiFilename: .\ckz_1KTC.tmp
'     osErrorInfo: Access is denied.
'     CurrentDir: C:\WINDOWS\system32
'     LoggedOnUser: IUSR_CHILKAT
'     ansiFilename: .\ckz_1KTC.tmp
'     Failed to open output Zip file
'     zipFilename: .\ckz_1KTC.tmp
'     Retrying with a new temp filename
'     Failed to open file (2)
'     ansiFilename: .\ckz2_4GUZ.tmp
'     osErrorInfo: Access is denied.
'     CurrentDir: C:\WINDOWS\system32
'     LoggedOnUser: IUSR_CHILKAT
'     ansiFilename: .\ckz2_4GUZ.tmp
'     Failed to open output Zip file
'     zipFilename: .\ckz2_4GUZ.tmp
'     tempFileName: .\ckz2_4GUZ.tmp
'     Cannot open temporary file

'  The error log tells us that the calling process's current
'  working directory is c:\WINDOWS\system32, and it's trying
'  to write ".\something.tmp".  Obviously that's not going to work
'  because you can't write to c:\WINDOWS\system32 from ASP.

'  To fix, set the TempDir to a directory that is writable.
'  In this case we'll use c:\inetpub\wwwroot\temp, which is
'  a virtual directory we've previously setup on this web server
'  with write capability.

'  Also, if you don't specify a path in NewZip, you're creating
'  a zip in the current working directory.  Provide a path such
'  as c:\inetpub\wwwroot\myZips  (you can alternatively use Server.MapPath
'  rather than hard-coded absolute paths)

'  Now, for the 2nd try, which will work this time:
zip.NewZip "c:/inetpub/wwwroot/myZips/test.zip"

zip.TempDir = "c:/inetpub/wwwroot/temp"

'  Append a directory tree.
recurse = 1
zip.AppendFiles "c:/inetpub/wwwroot/data/*",recurse

'  Now it worked!
success = zip.WriteZipAndClose()
If (success <> 1) Then
    Response.Write Server.HtmlEncode(zip.LastErrorText) & "<br>"
Else
    Response.Write Server.HtmlEncode("Zip Created!") & "<br>"
End If


%>
</body>
</html>

 

© 2000-2026 Chilkat Software, Inc. All Rights Reserved.