private void btnFileEncrypt_Click(object sender, EventArgs e) { try { if (comboBox1.SelectedItem == null) { MessageBox.Show("No USB Flash drive attached. Please attach one."); return; } if (filesToEncrypt.Count == 0) { MessageBox.Show("Select one or more files."); return; } else { pb.ShowDialog(); if (!pb.pwordok) { return; } } label4.Text = "Please Wait..."; enabledisableComponents(false); label4.Enabled = true; UsbDrive selectedUsb = (UsbDrive)comboBox1.SelectedItem; string secretKey = selectedUsb.serialNumber + pb.password; MyEncryptor enc = new MyEncryptor(secretKey); foreach (string fileToEncrypt in filesToEncrypt) { string encryptedFileName = getEncryptFileName(fileToEncrypt); if (encryptedFileName == "") { MessageBox.Show("Invalid File : " + filesToEncrypt); continue; } enc.Encrypt(fileToEncrypt, selectedUsb.driveLetter + encryptedFileName); FileInfo ff = new FileInfo(selectedUsb.driveLetter + encryptedFileName); File.SetAttributes(ff.FullName, FileAttributes.System); File.SetAttributes(ff.FullName, FileAttributes.Hidden); } //Copying the decrypting module FileInfo fsrc = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "TheDecryptor.exe"); FileInfo fdest = new FileInfo(selectedUsb.driveLetter + @"\" + "TheDecryptor.exe"); if (!fdest.Exists) { fsrc.CopyTo(fdest.FullName); } enabledisableComponents(true); label4.Text = ""; MessageBox.Show("All the files Encrypted Successfully."); } catch (Exception ex) { MessageBox.Show(ex.Message); } }