private void btnAUTOCompress_Click(object sender, EventArgs e) { const string LOG_TAG = "AUTO Compress: "; OpenFileDialog ofd = new OpenFileDialog(); ofd.AddExtension = true; ofd.CheckFileExists = true; ofd.CheckPathExists = true; ofd.ShowReadOnly = true; ofd.Title = "Open File..."; ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { string fileName = ofd.FileName; if (fileName != null && fileName != "") { FileInfo fInfo = new FileInfo(fileName); this.writeToConsole(LOG_TAG + "Opening: " + fInfo.FullName); using (FileStream instream = new FileStream(fInfo.FullName, FileMode.Open, FileAccess.Read)) { this.writeToConsole(LOG_TAG + "Reading file..."); byte[] input = new byte[instream.Length]; instream.Read(input, 0, input.Length); this.writeToConsole(LOG_TAG + "Compressing..."); CompressType usedType; byte[] output = CompressUtils.compress_auto(input, out usedType); this.writeToConsole("Compressed With: " + usedType.ToString()); using (FileStream outstream = new FileStream(fInfo.FullName + "." + usedType.ToString(), FileMode.Create, FileAccess.Write)) { this.writeToConsole(LOG_TAG + "Writing file: " + fInfo.FullName + "." + usedType.ToString()); outstream.Write(output, 0, output.Length); } this.writeToConsole(LOG_TAG + "Done!"); } } } }