AssemblyCSharp.FileHelper.WriteFileAtomic C# (CSharp) Méthode

WriteFileAtomic() public static méthode

public static WriteFileAtomic ( string filePath, byte contents, bool deleteOnError ) : void
filePath string
contents byte
deleteOnError bool
Résultat void
        public static void WriteFileAtomic(string filePath, byte[] contents, bool deleteOnError)
        {
            var tempPath = CreateTmpName(filePath);
            try
            {
            CreateNonExistentDirectory(Path.GetDirectoryName(filePath));
            File.WriteAllBytes(tempPath, contents);
            DeleteFile(filePath);
            File.Move(tempPath, filePath);
            }
            catch (Exception)
            {
            if (deleteOnError)
            {
                DeleteFileSilently(filePath);
            }

            DeleteFileSilently(tempPath);
            throw;
            }
        }