private static void WriteOutputFile(FileAnalyzerOptions options, FileResult[] fileResults)
 {
     using (var stream = new StreamWriter(options.OutputFilespec))
     {
         try
         {
             if ((options.Switches & FileAnalyzerOptionTypes.IncludeHeader) == FileAnalyzerOptionTypes.IncludeHeader)
             {
                 stream.WriteLine("Path / Filename,File Type Descriptor,MD5 Hash");
             }
             foreach (var result in fileResults)
             {
                 stream.WriteLine($"{result.Filespec},{result.FileType},{result.HashValue}");
             }
         }
         catch (Exception ex)
         {
             throw;
         }
         finally
         {
             stream.Close();
         }
     }
 }
        private static void ValidateOptions(FileAnalyzerOptions options)
        {
            if (File.Exists(options.OutputFilespec))
            {
                Console.WriteLine($"Output file {options.OutputFilespec} exists. Do you wish to overwrite it? (Y/N)");

                ConsoleKeyInfo ki;
                do
                {
                    ki = Console.ReadKey(true);
                } while(ki.Key != ConsoleKey.Y && ki.Key != ConsoleKey.N);
                if (ki.Key == ConsoleKey.Y)
                {
                    File.Delete(options.OutputFilespec);
                }
                else
                {
                    throw new Exception("Output file already exists. Please choose a new file and try again.");
                }
            }
        }
 public BulkFileAnalyzer(FileAnalyzerOptions options)
 {
     this.Options = options;
 }