Knight Data Access Layer
CompressFile Method
Example 




KellermanSoftware.NetDataAccessLayer Namespace > Compression Class : CompressFile Method
Compress a file in isolated storage using LZO compression
Syntax
Public Sub CompressFile( _
   ByVal inputFilePath As String, _
   ByVal outputFilePath As String _
) 
Dim instance As Compression
Dim inputFilePath As String
Dim outputFilePath As String
 
instance.CompressFile(inputFilePath, outputFilePath)
public void CompressFile( 
   string inputFilePath,
   string outputFilePath
)
public: void CompressFile( 
   string* inputFilePath,
   string* outputFilePath
) 
public:
void CompressFile( 
   String^ inputFilePath,
   String^ outputFilePath
) 

Parameters

inputFilePath
outputFilePath
Example
string inputString = "".PadRight(1000, 'z');
            byte[] inputBytes = Encoding.UTF8.GetBytes(inputString);
             
            #if SILVERLIGHT
            IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
            #else
            IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForDomain();
            #endif
             
            //Create the input file
            string inputFilePath = "InputFile.txt";
            using (IsolatedStorageFileStream outputStream = new IsolatedStorageFileStream(inputFilePath, FileMode.Create, FileAccess.Write, FileShare.None, store))
            {
                outputStream.Write(inputBytes,0,inputBytes.Length);
            }
             
            //Compress it
            string compressedPath = "Compressed.txt";
            Compression compression = new Compression(store);
            compression.CompressFile(inputFilePath,compressedPath);
             
            //Decompress
            string uncompressedPath = "Uncompressed.txt";
            compression.DecompressFile(compressedPath,uncompressedPath);
Dim inputString As String = "".PadRight(1000, "z"c)
            Dim inputBytes() As Byte = Encoding.UTF8.GetBytes(inputString)
             
            #If SILVERLIGHT Then
            Dim store As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()
            #Else
            Dim store As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForDomain()
            #End If
             
            'Create the input file
            Dim inputFilePath As String = "InputFile.txt"
            Using outputStream As New IsolatedStorageFileStream(inputFilePath, FileMode.Create, FileAccess.Write, FileShare.None, store)
            	outputStream.Write(inputBytes,0,inputBytes.Length)
            End Using
             
            'Compress it
            Dim compressedPath As String = "Compressed.txt"
            Dim compression As New Compression(store)
            compression.CompressFile(inputFilePath,compressedPath)
             
            'Decompress
            Dim uncompressedPath As String = "Uncompressed.txt"
            compression.DecompressFile(compressedPath,uncompressedPath)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Compression Class
Compression Members