Ejemplo n.º 1
0
        private void buttonCompress_Click(object sender, EventArgs e)
        {
            OpenFile("All Files(*.*)|*.*");

            if (_openedFile == null)
            {
                return;
            }

            try
            {
                byte[] data      = CompressUtil.Compress(_openedFile);
                string validPath = GetValidFilePath(_openedFile.FullName + COMPRESSED_FILE_EXTENTION);
                LogUtil.Log("Writing file to disk at: " + validPath);
                File.WriteAllBytes(validPath, data);
                LogUtil.Log("Compressing finished! File size:" + new FileInfo(validPath).Length + "\n");
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
                LogUtil.Log("Error happend! Working proccess stopped.\n");
            }
        }
Ejemplo n.º 2
0
        private void buttonDecompress_Click(object sender, EventArgs e)
        {
            OpenFile("Compressed File(*" + COMPRESSED_FILE_EXTENTION + "|*" + COMPRESSED_FILE_EXTENTION);

            if (_openedFile == null)
            {
                return;
            }

            try
            {
                byte[] data = CompressUtil.Decompress(_openedFile);
                // try write file to original file name
                string validPath = GetValidFilePath(_openedFile.FullName.Substring(0, _openedFile.FullName.Length - 5));
                LogUtil.Log("Writing file to disk at: " + validPath);
                File.WriteAllBytes(validPath, data);
                LogUtil.Log("Decompressing finished!");
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
                LogUtil.Log("Error happend! Working proccess stopped.\n");
            }
        }