Пример #1
0
 public void Populate(UserData data)
 {
     this.data = data;
     dirBox.Text = data.filePath;
     passwordBox.Text = data.password;
     driveLetterBox.Text = data.driveLetter;
 }
Пример #2
0
 public static bool UnMount(UserData data)
 {
     Process process;
     process = Process.Start(@"D:\Program Files\TrueCrypt\TrueCrypt.exe", @"/d " + data.driveLetter + @" /q");
     process.WaitForExit();
     return Convert.ToBoolean(process.ExitCode);
 }
Пример #3
0
 public SettingsForm(UserData data)
 {
     InitializeComponent();
     this.data = data;
     dirBox.Text = data.filePath;
     passwordBox.Text = data.password;
     driveLetterBox.Text = data.driveLetter;
 }
Пример #4
0
        public static bool Mount(UserData data)
        {
            Process process;
            process = Process.Start(@"D:\Program Files\TrueCrypt\TrueCrypt.exe", @"/v " + data.filePath + @" /p " + data.password + @" /l " + data.driveLetter + @" /e /q");
            process.WaitForExit();

            return Convert.ToBoolean(process.ExitCode);
        }
Пример #5
0
        /// <summary>
        /// Updates the truecrypt file so that dropbox will recognize it as an updated file and sync it.
        /// </summary>
        /// <returns>
        /// true if the truecrypt file is updated successfully
        /// false if the updating the truecrypt file throws an exception
        /// </returns>
        static bool UpdateFile(UserData data)
        {
            FileInfo fileInfo;

            try {
                fileInfo = new FileInfo(data.filePath);
                fileInfo.LastWriteTime = DateTime.Now;
                return true;
            } catch(Exception) {
                return false;
            }
        }
Пример #6
0
 //
 // Summary:
 //     Saves the single user data to "Data.dat" in "%appdata%\\Crypto".
 //     NOTE: Deletes all current contents on the file.
 //
 // Parameters:
 //   saveData:
 //     The UserData struct to save.
 //
 // Exceptions:
 //
 //   System.PlatformNotSupportedException:
 //     Environment.GetFolderPath - The current platform is not supported.
 //
 //   System.ArgumentException:
 //     saveData contains a invalid file path or one of saveData's members is a zero-length string or contains only white space
 //
 //   System.ArgumentNullException:
 //     saveData is null.
 //
 //   System.IO.PathTooLongException:
 //     The specified path, file name, or both exceed the system-defined maximum
 //     length. For example, on Windows-based platforms, paths must be less than
 //     248 characters, and file names must be less than 260 characters.
 //
 //   System.IO.IOException:
 //     Directory.CreateDirectory: The directory specified by path is a file.-or-The network name is not known.
 //     File.Open: An I/O error occurred while opening the file.
 //
 //   System.UnauthorizedAccessException:
 //     Directory.CreateDirectory: The caller does not have the required permission.
 //     File.Open: path specified a file that is read-only.-or- This operation is not supported
 //     on the current platform.-or- path specified a directory.-or- The caller does
 //     not have the required permission. -or-mode is System.IO.FileMode.Create and
 //     the specified file is a hidden file.
 //
 //   System.NotSupportedException:
 //     folderPath is in an invalid format.
 public static void SaveData(UserData saveData)
 {
     try {
         string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Crypto";
         if (saveData == null) throw new ArgumentNullException("saveData");
         if (!saveData.isComplete()) throw new ArgumentException("saveData contains a invalid file path or one of saveData's members is a zero-length string or contains only white space", "saveData");
         if (!Directory.Exists(folderPath))
             Directory.CreateDirectory(folderPath);
         using (BinaryWriter bw = new BinaryWriter(File.Open(folderPath + "\\Data.dat", FileMode.Create))) {
             bw.Write(1);
             bw.Write(saveData.filePath);
             bw.Write(saveData.password);
             bw.Write(saveData.driveLetter);
             bw.Close();
         }
     }
     catch (Exception e) {
         throw e;
     }
 }
Пример #7
0
 public static UserData[] LoadData()
 {
     UserData[] loadData;
     try {
         string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Crypto";
         if (!Directory.Exists(path))
             Directory.CreateDirectory(path);
         using (BinaryReader br = new BinaryReader(File.Open(path + "\\Data.dat", FileMode.Open))) {
             loadData = new UserData[br.ReadInt32()];
             for (int i = 0; i < loadData.Length; i++) {
                 loadData[i] = new UserData();
                 loadData[i].filePath = br.ReadString();
                 loadData[i].password = br.ReadString();
                 loadData[i].driveLetter = br.ReadString();
                 br.Close();
             }
         }
     } catch (FileNotFoundException) { throw new DataFileNotFoundException();  }
     catch (Exception e) { throw e; }
     return loadData;
 }
Пример #8
0
 public SettingsForm()
 {
     InitializeComponent();
     data = new UserData();
 }