VB.NET Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB.NET Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
PFX
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression
Misc

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

Byte Array
VB.NET FTPS
System.IO

 

 

 

 

 

 

FTP Upload Encrypted and Compressed

Download: Chilkat .NET Assemblies

Compress and encrypt a file, and upload it to an FTP server. Then do the reverse (download, decrypt, inflate).

Dim ftp As New Chilkat.Ftp2()

Dim success As Boolean

'  Any string unlocks the component for the 1st 30-days.
success = ftp.UnlockComponent("Anything for 30-day trial")
If (success <> true) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


Dim crypt As New Chilkat.Crypt2()

'  Any string unlocks the component for the 1st 30-days.
success = crypt.UnlockComponent("Anything for 30-day trial")
If (success <> true) Then
    MsgBox(crypt.LastErrorText)
    Exit Sub
End If


ftp.Hostname = "www.example-code.com"
ftp.Username = "***"
ftp.Password = "***"

'  Connect and login to the FTP server.
success = ftp.Connect()
If (success <> true) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


'  Change to the remote directory where the file will be uploaded.
success = ftp.ChangeRemoteDir("junk")
If (success <> true) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


'  Read the file into memory.
Dim fileData As New ByteData()
fileData = crypt.ReadFile("hamlet.xml")
If (fileData Is Nothing ) Then
    MsgBox(crypt.LastErrorText)
    Exit Sub
End If


Dim compressedData As New ByteData()
compressedData = crypt.CompressBytes(fileData)

'  Use 128-bit AES encryption, in CBC mode.
crypt.CryptAlgorithm = "aes"
crypt.CipherMode = "cbc"
crypt.KeyLength = 128

crypt.SetEncodedKey("0123456789ABCDEF","ascii")
crypt.SetEncodedIV("0123456789ABCDEF","ascii")

Dim encryptedData As New ByteData()
encryptedData = crypt.EncryptBytes(compressedData)

'  Upload from a byte array.
Dim remoteFilename As String
remoteFilename = "hamlet.dat"

success = ftp.PutFileFromBinaryData(remoteFilename,encryptedData)
If (success <> true) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


'  Now do the reverse:
Dim encryptedData2 As New ByteData()
encryptedData2 = ftp.GetRemoteFileBinaryData(remoteFilename)
If (encryptedData2 Is Nothing ) Then
    MsgBox(ftp.LastErrorText)
    Exit Sub
End If


'  Decrypt:
Dim decryptedData As New ByteData()
decryptedData = crypt.DecryptBytes(encryptedData2)

'  Inflate:
Dim inflatedData As New ByteData()
inflatedData = crypt.InflateBytes(decryptedData)

'  Save the decrypted/inflated data to a file.
success = crypt.WriteFile("hamlet2.xml",inflatedData)
If (success <> true) Then
    MsgBox(crypt.LastErrorText)
    Exit Sub
End If


ftp.Disconnect()

MsgBox("File Uploaded and Downloaded!")
 

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

Mail Component · XML Parser