예제 #1
0
        private void btnSelectFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.RestoreDirectory = true;
            //fileDialog.InitialDirectory = @"C:\";
            fileDialog.Title           = "Select File";
            fileDialog.Filter          = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            fileDialog.FilterIndex     = 2;
            fileDialog.DefaultExt      = "txt";
            fileDialog.CheckFileExists = false;
            fileDialog.ValidateNames   = false;
            fileDialog.CheckPathExists = true;
            fileDialog.Multiselect     = false;

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                info = new FileInfo(fileDialog.FileName);
                dataCryptor.inPutFilePath(fileDialog.FileName);
                dataCryptor.FileType(info.Extension);
                txtFilePath.Text = info.Name;
                dataCryptor.FileType(info.Name.Substring(0, info.Name.Length - info.Extension.Length), info.Extension);
                label5.Text = info.Extension;
            }
        }
예제 #2
0
        private void btnSelectFile_Click(object sender, EventArgs e)
        {
            try {
                ReadDataPath();
                OpenFileDialog fileDialog = new OpenFileDialog();
                fileDialog.RestoreDirectory = true;
                fileDialog.Title            = "Select File";
                fileDialog.Filter           = "data files (*.enc)|*.enc";
                fileDialog.FilterIndex      = 1;
                fileDialog.DefaultExt       = "enc";
                fileDialog.CheckFileExists  = false;
                fileDialog.ValidateNames    = false;
                fileDialog.CheckPathExists  = true;
                fileDialog.Multiselect      = false;


                if (fileDialog.ShowDialog() == DialogResult.OK)
                {
                    info = new FileInfo(fileDialog.FileName);
                    dataCryptor.inPutFilePath(fileDialog.FileName);
                    dataCryptor.FileType(info.Extension);
                    txtFileName.Text = info.Name;
                    dataCryptor.FileType(info.Name.Substring(0, info.Name.Length - info.Extension.Length), info.Extension);
                    dataCryptor.outPutFilePath(decrepted_file_path);
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #3
0
        private void btnBackup_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtFolderName.Text))
                {
                    throw new Exception("Select folder to backup file");
                }
                timer1.Enabled = true;
                timer1.Start();

                FileInfo infor = new FileInfo(Application.StartupPath + "/CASHDESKDB.mdf");
                info = new FileInfo(infor.FullName);
                dataCryptor.inPutFilePath(infor.FullName);
                dataCryptor.FileType(info.Extension);
                dataCryptor.FileType(info.Name.Substring(0, info.Name.Length - info.Extension.Length), info.Extension);
                dataCryptor.isDeletePlainFile(false);
                dataCryptor.EncryptFile();

                FileInfo infor2 = new FileInfo(Application.StartupPath + "/CASHDESKDB_log.ldf");
                info2 = new FileInfo(infor2.FullName);
                dataCryptor2.inPutFilePath(infor2.FullName);
                dataCryptor2.FileType(info2.Extension);
                dataCryptor2.FileType(info2.Name.Substring(0, info2.Name.Length - info2.Extension.Length), info2.Extension);
                dataCryptor2.isDeletePlainFile(false);
                dataCryptor2.EncryptFile();
                MessageBox.Show("Backup Sucessfull", "Cashdesk", MessageBoxButtons.OK, MessageBoxIcon.Information);
                timer1.Stop();
                pictureWait.Visible = false;
                lblWait.Visible     = false;
            }
            catch (System.UnauthorizedAccessException)
            {
                MessageBox.Show("Access to File is denied for backup", "Cashdesk", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            catch (Exception ex)
            {
                pictureWait.Visible = false;
                lblWait.Visible     = false;
                timer1.Stop();
                MessageBox.Show(ex.Message, "Cashdesk", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }