Exemplo n.º 1
0
        private void btnDecompress_Click(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog();
            if (sfd.ShowDialog() == DialogResult.Cancel)
                return;

            var offset = numOffset.Value;
            var length = numLength.Value;

            if (_compressionFormat == null)
                _compressionFormat = new CompositeCTRFormat();

            var fs = File.OpenRead(txtFilePath.Text);
            fs.Seek((long) offset, SeekOrigin.Begin);

            if (_compressionFormat.Supports(fs, (long)length))
            {
                var os = File.Create(sfd.FileName);
                _compressionFormat.Decompress(fs, (long)length, os);
                os.Close();
            }
            else
                MessageBox.Show(@"This file is not is a supported format.");
                
            fs.Close();

        }
Exemplo n.º 2
0
        private void btnCompress_Click(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog();
            if (sfd.ShowDialog() == DialogResult.Cancel)
                return;

            var offset = numOffset.Value;
            var length = numLength.Value;

            if (_compressionFormat == null)
                _compressionFormat = new CompositeCTRFormat();

            var compression = _compressionFormat.GetCompression(cmbAlgorithm.SelectedIndex);
            
            var fs = File.OpenRead(txtFilePath.Text);
            fs.Seek((long) offset, SeekOrigin.Begin);

            var os = File.Create(sfd.FileName);
            compression.Compress(fs, (long)length, os);
            os.Close();

            fs.Close();
        }