Reading files asynchronously
In this section, we will read text from a file asynchronously. We will be building upon the code from the previous section that writes the text to a file asynchronously.
The following steps will add our asynchronous read method and update the Program.cs
file to run our asynchronous code:
- In the
FileReadWriteAsync
class, add the following method:public static async Task<string> ReadTextAsync() { string filePath = @"C:\Temp\Greetings.txt"; using (FileStream fileStream = new FileStream( filePath, FileMode.Open, FileAccess.Read, FileShare.Read...