using System; using System.IO; using System.Text; using System.Threading.Tasks; namespace Example { class Program { static async Task Main(string[] args) { using (FileStream stream = new FileStream("example.txt", FileMode.Create)) { using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8)) { await writer.WriteAsync("Hello World!"); await writer.FlushAsync(); } } } } }In this example, a new file "example.txt" is created using FileStream class. The StreamWriter instance is created using the UTF8 encoding. Then, "Hello World!" is written to the file, followed by the FlushAsync method to flush any pending data to the file. The package library for this code is the .NET Core library.