private void deleteAllBackupLogsToolStripMenuItem_Click(object sender, EventArgs e)//delete Logs { Microsoft.VisualBasic.MsgBoxResult ANS = Microsoft.VisualBasic.Interaction.MsgBox("Are you sure you want DELETE ALL backup logs?\nThis operation CANNOT be undo.", (Microsoft.VisualBasic.MsgBoxStyle) 292, "Delete Logs"); if (ANS == Microsoft.VisualBasic.MsgBoxResult.Yes) { try { DirectoryInfo dir = new DirectoryInfo(LOC); foreach (var file in dir.GetFiles("KSP_backup_*.log")) { Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(LOC + "/" + file.Name); } DirectoryInfo dir2 = new DirectoryInfo(LOC + "/KSP_Data/"); foreach (var file in dir2.GetFiles("output_log_backup_*.txt")) { Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(LOC + "/KSP_Data/" + file.Name); } DirectoryInfo dir3 = new DirectoryInfo(LOC + "/KSP_x64_Data/"); foreach (var file in dir3.GetFiles("output_log_backup_*.txt")) { Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(LOC + "/KSP_x64_Data/" + file.Name); } Microsoft.VisualBasic.Interaction.MsgBox("Done.", Microsoft.VisualBasic.MsgBoxStyle.Information, "Delete Logs"); } catch { Microsoft.VisualBasic.Interaction.MsgBox("Looks like something is wrong when trying to delete logs\nPlease close the program that may using the backup log and try again.", Microsoft.VisualBasic.MsgBoxStyle.Exclamation, "Delete Logs"); } } else { Microsoft.VisualBasic.Interaction.MsgBox("Cancelled.", Microsoft.VisualBasic.MsgBoxStyle.Information, "Delete Logs"); } }
private void DeleteGameData_Click(object sender, EventArgs e)//delete game data { string msg = ""; msg = msg + "/" + "GameData_" + GameDataDataInformation.Text + "\n"; msg = msg + "/" + "saves_" + GameDataDataInformation.Text + "\n"; msg = msg + "/" + GameDataDataInformation.Text + "_buildID.txt" + "\n"; msg = msg + "/" + GameDataDataInformation.Text + "_buildID64.txt" + "\n"; if (Directory.Exists(LOC + "/CKAN")) { /* * msg = msg + "/CKAN/" + GameDataDataInformation.Text + "_compatible_ksp_versions.json" + "\n"; * msg = msg + "/CKAN/" + GameDataDataInformation.Text + "_GUIConfig.xml" + "\n"; */ msg = msg + "/CKAN/" + GameDataDataInformation.Text + "_installed-default.ckan" + "\n"; msg = msg + "/CKAN/" + GameDataDataInformation.Text + "_registry.json" + "\n"; } Microsoft.VisualBasic.MsgBoxResult ANS = Microsoft.VisualBasic.Interaction.MsgBox("Are you sure you want DELETE\n" + msg + "?\nThis operation CANNOT be undo.", (Microsoft.VisualBasic.MsgBoxStyle) 292, "Delete GameData"); if (ANS == Microsoft.VisualBasic.MsgBoxResult.Yes) { System.Diagnostics.Process.Start(LOC); string Return = Microsoft.VisualBasic.Interaction.InputBox("Here is the game root folder,\nPlease check again and enter the name of this GameData below:", "Delete GameData"); if (Return == GameDataDataInformation.Text) { Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory(LOC + "/GameData_" + GameDataDataInformation.Text, Microsoft.VisualBasic.FileIO.DeleteDirectoryOption.DeleteAllContents); Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory(LOC + "/saves_" + GameDataDataInformation.Text, Microsoft.VisualBasic.FileIO.DeleteDirectoryOption.DeleteAllContents); try { Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(LOC + "/" + GameDataDataInformation.Text + "_buildID.txt"); } catch { } try { Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(LOC + "/" + GameDataDataInformation.Text + "_buildID64.txt"); } catch { } if (Directory.Exists(LOC + "/CKAN")) { /* * try * { * Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(LOC + "/CKAN/" + GameDataDataInformation.Text + "_compatible_ksp_versions.json"); * } * catch { } * try * { * Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(LOC + "/CKAN/" + GameDataDataInformation.Text + "_GUIConfig.xml"); * } * catch { } */ try { Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(LOC + "/CKAN/" + GameDataDataInformation.Text + "_installed-default.ckan"); } catch { } try { Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(LOC + "/CKAN/" + GameDataDataInformation.Text + "_registry.json"); } catch { } } //done. Microsoft.VisualBasic.Interaction.MsgBox("Done.", Microsoft.VisualBasic.MsgBoxStyle.Information, "Delete GameData"); ReloadList(); } else if (Return == "") { goto exit; } else { Microsoft.VisualBasic.Interaction.MsgBox("Wrong name, files and folders will not be delete.", Microsoft.VisualBasic.MsgBoxStyle.Information, "Delete GameData"); goto exit; } } else if (ANS == Microsoft.VisualBasic.MsgBoxResult.No) { goto exit; } exit :; }