public void WriteToFolder(string bookFolderPath) { string tempFilePath; var metaDataPath = MetaDataPath(bookFolderPath); using (var temp = TempFile.InFolderOf(metaDataPath)) { tempFilePath = temp.Path; } RobustFile.WriteAllText(tempFilePath, Json); if (RobustFile.Exists(metaDataPath)) { RobustFile.Replace(tempFilePath, metaDataPath, Path.ChangeExtension(metaDataPath, "bak")); } else { RobustFile.Move(tempFilePath, metaDataPath); } }