예제 #1
0
        private void decodeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (FolderList.SelectedNode != null && FolderList.SelectedNode.Tag != null)
            {
                TreeNode SelectedNode = FolderList.SelectedNode;

                var ext = (Path.GetExtension(SelectedNode.Tag.ToString()) ?? string.Empty).ToLower();
                if (FileCryptor.DRIVE_CRYPT_EXTENSTION == ext)
                {
                    var atributes = File.GetAttributes(SelectedNode.Tag.ToString());
                    if ((atributes & FileAttributes.Directory) != FileAttributes.Directory)
                    {
                        while (IsFileLocked(SelectedNode.Tag.ToString()))
                        {
                            Thread.Sleep(100);
                        }
                        string filePath    = SelectedNode.Tag.ToString();
                        string newFilePath = filePath.Replace(GDriveManager.MySharingFolder + Path.DirectorySeparatorChar, "");
                        newFilePath = newFilePath.Replace(GDriveManager.SharedWithMeFolder + Path.DirectorySeparatorChar, "");
                        newFilePath = newFilePath.Replace(FileCryptor.DRIVE_CRYPT_EXTENSTION, "");
                        FileCryptor.DecryptFile(SelectedNode.Tag.ToString(), newFilePath, _authorizationForm._userCryptor);
                    }
                }
            }
            else
            {
                MessageBox.Show("Select the item (left click on it) and try again!", "Drive Crypt", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #2
0
        public void onCreateDecryptedEvent(object source, FileSystemEventArgs e)
        {
            var ext = (Path.GetExtension(e.FullPath) ?? string.Empty).ToLower();

            if (_extensionsToBeIgnoredByWatcher[0] == ext)
            {
                string         newPath   = this._directoryPath + "\\Shared with me";
                FileAttributes atributes = File.GetAttributes(e.FullPath);
                if ((atributes & FileAttributes.Directory) != FileAttributes.Directory)
                {
                    while (IsFileLocked(e.FullPath))
                    {
                        //MessageBox.Show("The requested file " + Path.GetFileName(e.FullPath) + " already exists and is used by another process!", "Drive Crypt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //return;
                        Thread.Sleep(100);
                    }
                    string   newFilePath       = e.FullPath;
                    string   decryptedFile     = FileCryptor.DecryptFile(e.FullPath, _authorizationForm._userCryptor);
                    string[] decryptedFileName = decryptedFile.Split(Path.DirectorySeparatorChar);
                    string   toDelete          = newFilePath;
                    newPath = newFilePath.Replace(newPath, this._directoryPath);
                    string[] fileName = newPath.Split(Path.DirectorySeparatorChar);
                    newPath  = newPath.Replace(fileName.Last(), decryptedFileName.Last());
                    toDelete = toDelete.Replace(fileName.Last(), decryptedFileName.Last());
                    File.Copy(decryptedFile, newPath, true);
                    File.Delete(toDelete);
                    while (IsFileLocked(newPath))
                    {
                        //MessageBox.Show("The requested file " + Path.GetFileName(e.FullPath) + " already exists and is used by another process!", "Drive Crypt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //return;
                        Thread.Sleep(100);
                    }
                }
            }
        }
예제 #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            ofd.InitialDirectory = _directoryPath;
            ofd.Filter           = "Drive Crypt Files(*" + FileCryptor.DRIVE_CRYPT_EXTENSTION + ") | *" + FileCryptor.DRIVE_CRYPT_EXTENSTION;
            ofd.FilterIndex      = 1;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                FileCryptor.DecryptFile(ofd.FileName, _authorizationForm._userCryptor);
            }
        }