Exemple #1
0
 public static async Task WriteXmlAsync(this IFile file, XElement element)
 {
     using (var output = await file.CreateWrite())
     {
         await WriteXmlAsync(output, element);
     }
 }
Exemple #2
0
 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);
         }
 }
Exemple #3
0
 public async ValueTask DisposeAsync()
 {
     if (stored == null)
     {
         return;
     }
     stored.Seek(0, SeekOrigin.Begin);
     using (var output = await file.CreateWrite())
     {
         await stored.CopyToAsync(output);
     }
 }
Exemple #4
0
        public async Task SaveFile()
        {
            await semaphore.WaitAsync();

            {
                await using (var output = await file.CreateWrite())
                {
                    await JsonSerializer.SerializeAsync(output, ToJsonObject());
                }
            }
            semaphore.Release();
        }
Exemple #5
0
 public static Stream CreateWriteSync(this IFile file)
 {
     return(AsyncPump.Run <Stream>(() => file.CreateWrite()));
 }
Exemple #6
0
 public Task <Stream> RewriteStream() => file.CreateWrite();
Exemple #7
0
        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));
        }