{ SqlContext.Pipe.Send("Compression Selected"); FileInfo fileToCompress = new FileInfo(inputpath); FileInfo compressedFile = new FileInfo(outputpath); Compress(fileToCompress, compressedFile); return; } //option decompressor else if (option == "decomp") { SqlContext.Pipe.Send("Decompression Selected\n"); FileInfo fileToDecompress = new FileInfo(inputpath); FileInfo decompressedFile = new FileInfo(outputpath); Decompress(fileToDecompress, decompressedFile); return; } //help...because we all need this! :-) else if (option == "help") { help(); return; } } //Compression Code public static void Compress(FileInfo fileToCompress, FileInfo compressedFile) { using (FileStream originalFileStream = fileToCompress.OpenRead()) { if ((File.GetAttributes(fileToCompress.FullName) & FileAttributes.Hidden) != FileAttributes.Hidden & fileToCompress.Extension != ".gz") { using (FileStream compressedFileStream = File.Create(compressedFile + ".gz")) { (GZipStream compressionStream = new GZipStream(compressedFileStream, CompressionMode.Compress)) { originalFileStream.CopyTo(compressionStream); SqlContext.Pipe.Send("Compression Complete\n"); } } } } } //Help Code public static void help() { SqlContext.Pipe.Send("Help for CLR File Compressor\n"); SqlContext.Pipe.Send("The Proc Expects 3 params (ALL LOWERCASE):\n");
{ SqlContext.Pipe.Send("Compression Selected"); FileInfo fileToCompress = new FileInfo(inputpath); FileInfo compressedFile = new FileInfo(outputpath); Compress(fileToCompress, compressedFile); return; } //option decompressor else if (option == "decomp") { SqlContext.Pipe.Send("Decompression Selected\n"); FileInfo fileToDecompress = new FileInfo(inputpath); FileInfo decompressedFile = new FileInfo(outputpath); Decompress(fileToDecompress, decompressedFile); return; } //help...because we all need this! :-) else if (option == "help") { help(); return; } } //Compression Code public static void Compress(FileInfo fileToCompress, FileInfo compressedFile) { using (FileStream originalFileStream = fileToCompress.OpenRead()) { if ((File.GetAttributes(fileToCompress.FullName) & FileAttributes.Hidden) != FileAttributes.Hidden & fileToCompress.Extension != ".gz") { using (FileStream compressedFileStream = File.Create(compressedFile + ".gz")) { (GZipStream compressionStream = new GZipStream(compressedFileStream, CompressionMode.Compress)) { originalFileStream.CopyTo(compressionStream); SqlContext.Pipe.Send("Compression Complete\n"); } } } } } //Help Code public static void help() { SqlContext.Pipe.Send("Help for CLR File Compressor\n"); SqlContext.Pipe.Send("The Proc Expects 3 params (ALL LOWERCASE):\n");
SSIS%20Hybrid%20and%20Azure.docx