public FlushAsync ( CancellationToken cancellationToken ) : Task | ||
cancellationToken | CancellationToken | |
return | Task |
using System.IO; class Program { static async Task WriteToFileAsync(string filepath, byte[] data) { using (var stream = new FileStream(filepath, FileMode.OpenOrCreate)) { await stream.WriteAsync(data, 0, data.Length); await stream.FlushAsync(); // write all the data to the file } } }
using System.IO; class Program { static async Task WriteToMemoryAsync(byte[] data) { using (var stream = new MemoryStream()) { await stream.WriteAsync(data, 0, data.Length); await stream.FlushAsync(); // write all the data to the memory stream var result = Encoding.UTF8.GetString(stream.ToArray()); } } }Package Library: The `System.IO` namespace is part of the .NET standard library and is included in the `mscorlib.dll` assembly, which is a core part of the .NET framework. Therefore, no external package or library is required to use the `FileStream` class and its `FlushAsync` method in a C# application.
public FlushAsync ( CancellationToken cancellationToken ) : Task | ||
cancellationToken | CancellationToken | |
return | Task |