public bool ExistsInMapsFolder(string mapsFolder) { var mapsPath = mapsFolder ?? _serverContext.GetMapsDirectory(); var exists = File.Exists(Path.Combine(mapsPath, LocalFileName)); return(exists); }
public bool MoveToMapsFolder(MapModel map) { var tempFile = Path.Combine(_tempFolder, map.LocalFileName); var finalFile = Path.Combine(MapsDirectory ?? _server.GetMapsDirectory(), map.LocalFileName); if (File.Exists(finalFile)) { try { File.Delete(finalFile); } catch (Exception) { Console.WriteLine("Can't delete " + finalFile); return(false); } } int tries = 0; do { try { File.Move(tempFile, finalFile); return(true); } catch (Exception) { Console.WriteLine("Can't move " + finalFile); tries++; Thread.Sleep(1000); } } while (tries < 5); return(false); }