Example #1
0
 protected virtual void WriteError(
     Exception ex,
     string path,
     string indent)
 {
     LogHelpers.WriteFileError(ex, path, relativePath: Options.DisplayRelativePath, indent: indent);
 }
Example #2
0
 protected string ReadFile(
     string filePath,
     string basePath,
     Encoding encoding,
     SearchContext context,
     string indent = null)
 {
     try
     {
         using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
             using (var reader = new StreamReader(stream, encoding, detectEncodingFromByteOrderMarks: true))
             {
                 return(reader.ReadToEnd());
             }
     }
     catch (Exception ex) when(ex is IOException ||
                               ex is UnauthorizedAccessException)
     {
         EndProgress(context);
         LogHelpers.WriteFileError(ex, filePath, basePath, relativePath: Options.DisplayRelativePath, indent: indent);
         return(null);
     }
 }