C# Examples

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

C# Examples

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


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

Working with the HTTP Cache

Download: Chilkat .NET Assemblies

This C# example demonstrates how it is possible to work with the HTTP cache using the Chilkat.Cache class.

Chilkat.Cache cache = new Chilkat.Cache();

// Before doing anything, make sure the you tell the component where
// the cache is located.
cache.AddRoot("c:/cache1");

string url = "http://www.example-code.com/";

// Determine the cache filename for a given URL:
string cacheFilename = cache.GetFilename(url);
MessageBox.Show(cacheFilename);

// Is this url in our cache?
bool inCache = cache.IsCached(url);
if (inCache)
{
    MessageBox.Show(url + " is in the cache!");
    }
    
// Remove a url from cache.
cache.DeleteFromCache(url);
inCache = cache.IsCached(url);
if (!inCache)
{
    MessageBox.Show(url + " is NOT in the cache!");
}

// Add something to the cache manually.
string eTag = "v1.0";
// The expire time will be 14 days from now.
DateTime expire = DateTime.Now;
expire = expire.AddDays(14.0);
byte[] bData = System.Text.ASCIIEncoding.ASCII.GetBytes("This is a string");    
bool ok = cache.SaveToCache(url,expire,eTag,bData);
if (!ok)
{
    MessageBox.Show(cache.LastErrorText);
    }
    
// Fetch what we just inserted back from cache.
byte[] cachedData = cache.FetchFromCache(url);
if (cachedData.Length == 0)
{
    // Cache miss.
    MessageBox.Show(url + " not found in cache!");
    }

// What is the expiration date of the last resource fetched from cache?
MessageBox.Show("Expiration: " + Convert.ToString(cache.LastExpirationFetched));		    

// What is the etag of the last resource fetched from cache?
MessageBox.Show("Etag: " + Convert.ToString(cache.LastEtagFetched));	

// Was the last cache hit an expired entry?
if (cache.LastHitExpired)
{
    MessageBox.Show(cache.LastResourceFetched + " is expired!");
    
    // Let's delete the expired entry.
    cache.DeleteFromCache(cache.LastResourceFetched);
    
    // Or, we could've done this:
    cache.DeleteAllExpired();		    
    }    
    
// Delete everything in the cache:
cache.DeleteAll();


Important: The download for this example does not contain the ChilkatDotNet2.dll which
must be downloaded and installed separately at http://www.chilkatsoft.com/downloads.asp.
Once installed, add a reference to the DLL in the project by following the instructions at
http://www.example-code.com/csharp/step2.asp

 

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

Email Component · XML Parser