public static async Task WriteXmlAsync(this IFile file, XElement element) { using (var output = await file.CreateWrite()) { await WriteXmlAsync(output, element); } }
private static async Task CopyUsingStreams(IFile destination, IFile source, CancellationToken token, FileAttributes attributes) { using (var src = await source.OpenRead()) using (var dest = await destination.CreateWrite(attributes)) { await src.CopyToAsync(dest, 10240, token); } }
public async ValueTask DisposeAsync() { if (stored == null) { return; } stored.Seek(0, SeekOrigin.Begin); using (var output = await file.CreateWrite()) { await stored.CopyToAsync(output); } }
public async Task SaveFile() { await semaphore.WaitAsync(); { await using (var output = await file.CreateWrite()) { await JsonSerializer.SerializeAsync(output, ToJsonObject()); } } semaphore.Release(); }
public static Stream CreateWriteSync(this IFile file) { return(AsyncPump.Run <Stream>(() => file.CreateWrite())); }
public Task <Stream> RewriteStream() => file.CreateWrite();
private static async Task WriteEmptySecretFile(IFile secretFile) { await using var output = await secretFile.CreateWrite(); output.Write(new byte[] { 123, 125 }); // Utf8 for {} }
private async Task WriteWebConfig(IFile webConfig) { await using var outputStream = await webConfig.CreateWrite(); outputStream.Write(Encoding.UTF8.GetBytes(Model.WebConfig)); }