void SyncFileIfNotChanged(string filename, string newContents) { if (m_FileIOProvider.Exists(filename)) { var currentContents = m_FileIOProvider.ReadAllText(filename); if (currentContents == newContents) { return; } } m_FileIOProvider.WriteAllText(filename, newContents); }
void SyncFileIfNotChanged(string filename, string newContents) { try { if (m_FileIOProvider.Exists(filename) && newContents == m_FileIOProvider.ReadAllText(filename)) { return; } } catch (Exception exception) { Debug.LogException(exception); } m_FileIOProvider.WriteAllText(filename, newContents); }
private void CreateVsConfigIfNotFound() { try { var vsConfigFile = VsConfigFile(); if (m_FileIOProvider.Exists(vsConfigFile)) { return; } var content = $@"{{ ""version"": ""1.0"", ""components"": [ ""{Discovery.ManagedWorkload}"" ] }} "; m_FileIOProvider.WriteAllText(vsConfigFile, content); } catch (IOException) { } }
private static void BaseSave(string fileName, IHOTASCollection deviceList) { Logging.Log.Debug($"Saving profile as :{fileName}"); try { _fileIo.WriteAllText(fileName, JsonConvert.SerializeObject(deviceList, Formatting.Indented, new CustomJsonConverter())); } catch (Exception e) { Logging.Log.Debug(e); throw; } }
private void SyncFileIfNotChanged(string filename, string newContents) { if (m_fileIOProvider.Exists(filename)) { var currentContents = m_fileIOProvider.ReadAllText(filename); if (currentContents == newContents) { return; } try { LogDifference(filename, currentContents, newContents); } catch (Exception exception) { Console.WriteLine("Failed to log difference of {0}\n{1}", filename, exception); } } m_fileIOProvider.WriteAllText(filename, newContents); }