How to do it...

  1. Create a text file and two folders to contain the log files. We will, however, only create a single log file in the BackupLog folder. Name your text file taskFile.txt and copy it to the BackupLog folder. The MainLog folder will remain empty:
  1. In our AsyncDemo class, write a method to read the log file in the folder specified by the enum value:
      private async Task<int> ReadLog(LogType logType)      {         string logFilePath = String.Empty;         if (logType == LogType.Main)            logFilePath = @"C:\temp\Log\MainLog\taskFile.txt";         else if (logType == LogType.Backup)            logFilePath = @"C:\temp\Log\BackupLog\taskFile.txt"; string enumName = Enum.GetName(typeof(LogType), ...

Get C# 7 and .NET Core Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.