O'Reilly logo

C# 7 and .NET Core Cookbook by Dirk Strauss

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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), ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required