AssemblyCSharp.FileHelper.WriteAllTextAtomic C# (CSharp) Method

WriteAllTextAtomic() public static method

public static WriteAllTextAtomic ( string filePath, string value, bool deleteOnError ) : void
filePath string
value string
deleteOnError bool
return void
        public static void WriteAllTextAtomic(string filePath, string value, bool deleteOnError)
        {
            var tempPath = CreateTmpName(filePath);
            try
            {
            CreateNonExistentDirectory(Path.GetDirectoryName(filePath));
            File.WriteAllText(tempPath, value);
            DeleteFile(filePath);
            File.Move(tempPath, filePath);
            }
            catch (Exception)
            {
            if (deleteOnError)
            {
                DeleteFileSilently(filePath);
            }

            DeleteFileSilently(tempPath);
            throw;
            }
        }