Methods to compress file and decompress file using System.IO.Compression Method to compress a file. public void CompressFile ( string sourceFile, string destinationFile ) { // Check File exists in the source path if ( File .Exists ( sourceFile ) == false ) throw new FileNotFoundException ( ); // Create the streams and byte arrays byte [] buffer = null ; FileStream sourceStream = null ; FileStream destinationStream = null ; GZipStream compressedStream = null ; try { // Read the bytes from the source file into a byte array sourceStream = new FileStream ( sourceFile, FileMode .Open, FileAccess .Read, FileShare .Read ); // Read the source stream values into the buffer buffer = new byte [sourceStream.Length]; int checkCounter = sourceStream.Read ( buffer, 0, buffer.Length ); if ( checkCounter != buffer.Length ) { throw new ApplicationException ( ); } // Open the FileStream to write destinationStream = new FileStream ( destinationFile, FileMode ...
C#, OOPS, MVC, WCF, Architecture, SQL, Table, Triggers, Script and SQL Server