private void Check4FailedMigrationHD()
 {
     if (File.Exists(TrueCryptFilesNew.tcFileHDNewPath) && File.Exists(tcFileHDOldLoc.FileNamePath.Substring(0, tcFileHDOldLoc.FileNamePath.LastIndexOf("\\") + 1) + "oldtpdata.tc"))
     {
         migrationFileActionForm migUserQuestion = new migrationFileActionForm();
         DialogResult diaResult = migUserQuestion.ShowDialog();
         if (diaResult == DialogResult.Yes) //delete old tc files HD
         {
             string regKeyMigrationHD = (string)Microsoft.Win32.Registry.GetValue(DoTasksObj.regKeyName, "TFTAOld", ""); //get this here in case started with old file existing from previous run of utility
             if (regKeyMigrationHD != "")
             {
                 string[] oldFilePaths = regKeyMigrationHD.Split(new char[] { ',' });
                 foreach (var item in oldFilePaths)
                 {
                     File.Delete(item);
                 }
                 Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(DoTasksObj.regsubKeyName);
                 rk.DeleteValue("TFTAOld");
             }
             else
             {
                 File.Delete(tcFileHDOldLoc.FileNamePath.Substring(0, tcFileHDOldLoc.FileNamePath.LastIndexOf("\\") + 1) + "oldtpdata.tc");
                 File.Delete(tcFileHDOldLoc.FileNamePath.Substring(0, tcFileHDOldLoc.FileNamePath.LastIndexOf("\\") + 1) + "oldtsdata.tc");
             }
             return; //continue with utility
         }
         if (diaResult == DialogResult.Retry)
         {// delete existing new p and continue
             File.Delete(tcFileHDOldLoc.FileNamePath); //int the unlikely event that regkey does not exist
             tcFileHDOldLoc.FileNamePath = string.Empty;
             return;
         }
     }
 }
 private void Check4FailedMigrationTrav(int index2travUSBdrv)
 {
     //travdrv has tpdata on it. check for migration file on hd Use new HD location to find if old traveler file
     if (File.Exists(TrueCryptFilesNew.tcFileHDNewPath.Substring(0, TrueCryptFilesNew.tcFileHDNewPath.LastIndexOf("\\") + 1) + "oldtravtpdata.tc"))
     {
         migrationFileActionForm migUserQuestion = new migrationFileActionForm();
         // Change form text over to traveler questions
         migUserQuestion.delInitialExplain.Text = "A TrueCrypt TPDATA file (the P drive) exists on the Traveler Drive\n" + travUSBDrv[index2travUSBdrv].combo + "In addition an old Traveler TrueCrypt file exists \non the Hard Drive.This looks like a failed migration of user data from \nan old Traveler based Truecrypt file to a new Traveler TrueCrypt file.";
         migUserQuestion.delNewPStartTAutil.Text = "Delete the current Traveler TPDATA file. Continue the Tax-Aide Utility \nto create a new Traveler file and complete the migration that failed.";
         migUserQuestion.delOldTCFiles.Text = "Delete the old Traveler TrueCrypt file. Assumes data migration is \ndone correctly, and the old file is not needed. Warning - it \nwill be permanently deleted. Then continue the utility.";
         migUserQuestion.radBtGrpBox.Text += " for " + travUSBDrv[index2travUSBdrv].combo;
         DialogResult diaResult = migUserQuestion.ShowDialog();
         if (diaResult == DialogResult.Yes) //delete old tc file Trav
         {
             string regKeyMigrationTrav = (string)Microsoft.Win32.Registry.GetValue(DoTasksObj.regKeyName, "TFTATravOld", "");
             if (regKeyMigrationTrav != "")
             {
                 File.Delete(regKeyMigrationTrav);
                 Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(DoTasksObj.regsubKeyName);
                 rk.DeleteValue("TFTATravOld");
             }
             else
                 File.Delete(tcFileHDOldLoc.FileNamePath.Substring(0, tcFileHDOldLoc.FileNamePath.LastIndexOf("\\") + 1) + "oldtravtpdata.tc");
             return; //continue with utility
         }
         if (diaResult == DialogResult.Retry)
         {// delete existing new p and continue
             File.Delete(travUSBDrv[index2travUSBdrv].tcFilePoss);
             travUSBDrv[index2travUSBdrv].tcFilePoss = string.Empty;
             travTcFilePossCount--;
             return;
         }
     }
 }
 private void Check4FailedMigrationHD()
 {
     string regKeyMigrationHD = (string)Microsoft.Win32.Registry.GetValue(DoTasksObj.regKeyName, "TFTAOld", ""); //get this here in case started with old file existing from previous run of utility
     string tcMigFilePath =  Environment.GetEnvironmentVariable("HOMEDRIVE") + "\\"  + "oldtpdata.tc";
     if (DoTasksObj.osVer == 6)
     {
         string tcMigFilePath1 = Environment.GetEnvironmentVariable("PUBLIC") + "\\" + "oldtpdata.tc";
         if (!File.Exists(tcMigFilePath1) && File.Exists(tcMigFilePath))
         {//deals with case of v/W7 and oldtpdata exists at c root rather than public
             tcMigFilePath1 = tcMigFilePath;
         }
         tcMigFilePath = tcMigFilePath1;  //sets up public as path for V/W7 unless old exists in root
     }
     if (File.Exists(TrueCryptFilesNew.tcFileHDNewPath) && (File.Exists(tcMigFilePath)))
     {// we have old and new files existing therefore maybe failed migration
         migrationFileActionForm migUserQuestion = new migrationFileActionForm();
         DialogResult diaResult = migUserQuestion.ShowDialog();
         if (diaResult == DialogResult.Yes) //delete old tc files HD
         {
             if (regKeyMigrationHD != "")
             {
                 string[] oldFilePaths = regKeyMigrationHD.Split(new char[] { ',' });
                 foreach (var item in oldFilePaths)
                 {
                     File.Delete(item);
                 }
                 Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(DoTasksObj.regsubKeyName);
                 rk.DeleteValue("TFTAOld");
             }
             else
             {
                 File.Delete(tcMigFilePath);
                 File.Delete(tcMigFilePath.Substring(0, tcMigFilePath.LastIndexOf("\\") + 1) + "oldtsdata.tc");
             }
             return; //continue with utility
         }
         if (diaResult == DialogResult.Retry)
         {// delete existing new p and continue
             File.Delete(tcFileHDOldLoc.FileNamePath); //int the unlikely event that regkey does not exist
             tcFileHDOldLoc.FileNamePath = string.Empty;
             return;
         }
     }
     else
     {
         if (regKeyMigrationHD != "" && !File.Exists(tcMigFilePath))
         {//We have reg key set but no old file
             DialogResult mbResult = MessageBox.Show("There is a migration data flag set, but no old Hard Drive TPDATA file, \r\nDelete the Migration Flag?", DoTasksObj.mbCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Error); //Delete reg entries and return on OK, exit on cancel
             if (mbResult == DialogResult.OK)
             {
                 DeleteMigrationRegEntries(false);
                 return;
             }
             else
                 Environment.Exit(1);
         }
     }
 }