Move WriteAllTextSafe to correct location

This commit is contained in:
MidoriKami 2023-09-19 23:44:56 -07:00
parent c305c01dfd
commit 2b2a027fb0

View file

@ -609,7 +609,23 @@ public static class Util
}
}
}
/// <summary>
/// Overwrite text in a file by first writing it to a temporary file, and then
/// moving that file to the path specified.
/// </summary>
/// <param name="path">The path of the file to write to.</param>
/// <param name="text">The text to write.</param>
public static void WriteAllTextSafe(string path, string text)
{
var tmpPath = path + ".tmp";
if (File.Exists(tmpPath))
File.Delete(tmpPath);
File.WriteAllText(tmpPath, text);
File.Move(tmpPath, path, true);
}
/// <summary>
/// Dispose this object.
/// </summary>
@ -645,22 +661,6 @@ public static class Util
}
}
/// <summary>
/// Overwrite text in a file by first writing it to a temporary file, and then
/// moving that file to the path specified.
/// </summary>
/// <param name="path">The path of the file to write to.</param>
/// <param name="text">The text to write.</param>
public static void WriteAllTextSafe(string path, string text)
{
var tmpPath = path + ".tmp";
if (File.Exists(tmpPath))
File.Delete(tmpPath);
File.WriteAllText(tmpPath, text);
File.Move(tmpPath, path, true);
}
/// <summary>
/// Gets a random, inoffensive, human-friendly string.
/// </summary>