public void DeleteGame(AowGameType theGameType, string fileName) { if (!theGameType.Equals(AowGameType.Unknown)) { AowGame theGame = GetGameByType(theGameType); if (theGame != null && theGame.IsInstalled) { DirectoryInfo[] theFolders = new DirectoryInfo[] { theGame.EmailIn, theGame.EmailOut, theGame.Save }; string searchPattern = GetSearchPattern(fileName); foreach (DirectoryInfo folder in theFolders) { FileInfo[] matchingFiles = GetAllGameFiles(fileName, folder, searchPattern); if (matchingFiles.Length > 0) { foreach (FileInfo file in matchingFiles) { if (File.Exists(file.FullName)) { File.Delete(file.FullName); } } } } } } else { //If it's an unknown game just delete ClearCheckEmailFolder(fileName); } }
public void ArchiveEndedGame(AowGameType theGameType, string fileName, string endedFolderName) { if (!theGameType.Equals(AowGameType.Unknown)) { AowGame theGame = GetGameByType(theGameType); if (theGame != null && theGame.IsInstalled) { DirectoryInfo[] theFolders = new DirectoryInfo[] { theGame.EmailIn, theGame.EmailOut, theGame.Save }; string searchPattern = GetSearchPattern(fileName); foreach (DirectoryInfo folder in theFolders) { FileInfo[] matchingFiles = GetAllGameFiles(fileName, folder, searchPattern); if (matchingFiles.Length > 0) { string endedFolderPath = Path.Combine(folder.FullName, endedFolderName); if (!Directory.Exists(endedFolderPath)) { Directory.CreateDirectory(endedFolderPath); } DirectoryInfo theEndedFolder = new DirectoryInfo(endedFolderPath); foreach (FileInfo file in matchingFiles) { string newFileName = Path.Combine(theEndedFolder.FullName, file.Name); try { if (File.Exists(newFileName)) { File.Delete(newFileName); } //This is in a Try Catch incase it tries to move a non virtualized file in virtualization mode (UAC on) File.Move(file.FullName, newFileName); } catch { } } } } } } else { //If it's an unknown game just delete ClearCheckEmailFolder(fileName); } }