Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WriteAllTextAsync() [2/2]

static Task System.IO.File.WriteAllTextAsync ( string path,
string? contents,
Encoding encoding,
CancellationToken cancellationToken = default(CancellationToken) )
inlinestatic

Definition at line 698 of file File.cs.

699 {
700 if (path == null)
701 {
702 throw new ArgumentNullException("path");
703 }
704 if (encoding == null)
705 {
706 throw new ArgumentNullException("encoding");
707 }
708 if (path.Length == 0)
709 {
710 throw new ArgumentException(SR.Argument_EmptyPath, "path");
711 }
712 if (cancellationToken.IsCancellationRequested)
713 {
715 }
716 if (string.IsNullOrEmpty(contents))
717 {
718 new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read).Dispose();
719 return Task.CompletedTask;
720 }
722 }
static StreamWriter AsyncStreamWriter(string path, Encoding encoding, bool append)
Definition File.cs:631
static async Task InternalWriteAllTextAsync(StreamWriter sw, string contents, CancellationToken cancellationToken)
Definition File.cs:920
static Task FromCanceled(CancellationToken cancellationToken)
Definition Task.cs:3363
static Task CompletedTask
Definition Task.cs:1120

References System.SR.Argument_EmptyPath, System.IO.File.AsyncStreamWriter(), System.cancellationToken, System.Threading.Tasks.Task< TResult >.CompletedTask, System.IO.FileStream.Dispose(), System.Threading.Tasks.Task< TResult >.FromCanceled(), and System.IO.File.InternalWriteAllTextAsync().