示例#1
0
        private static string[] TryReadFileContent(string file, IMessageLogger messageLogger)
        {
            try
            {
                return(IoHelpers.ReadFileContent(file));
            }
            catch (IOException ex)
            {
                messageLogger.WriteExceptionMessage(
                    MessageSeverity.SetupError,
                    $"Could not access file '{file}'.", ex);

                return(Array <string> .Empty);
            }
            catch (UnauthorizedAccessException ex)
            {
                messageLogger.WriteExceptionMessage(
                    MessageSeverity.SetupError,
                    $"Could not access file '{file}'.", ex);

                return(Array <string> .Empty);
            }
            catch (DecoderFallbackException ex)
            {
                messageLogger.WriteExceptionMessage(
                    MessageSeverity.SetupError,
                    $"Cannot detect encoding for file '{file}'. Try to save the file as UTF8 or UTF16.", ex);

                return(Array <string> .Empty);
            }
        }