private void btnAUTODecompress_Click(object sender, EventArgs e) { const string LOG_TAG = "AUTO Decompress: "; 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 + "Decompressing..."); CompressType usedType; byte[] output = CompressUtils.decompress_auto(input, out usedType); if (usedType != CompressType.NULL) { this.writeToConsole("Detected Compression: " + usedType.ToString()); using (FileStream outstream = new FileStream(fInfo.FullName + ".de" + usedType.ToString(), FileMode.Create, FileAccess.Write)) { this.writeToConsole(LOG_TAG + "Writing file: " + fInfo.FullName + ".de" + usedType.ToString()); outstream.Write(output, 0, output.Length); } this.writeToConsole(LOG_TAG + "Done!"); } else { this.writeToConsole("Failed to detect valid compression format!"); } } } } }