Microsoft.VisualStudio.R.Package.DataInspect.DataImport.ImportDataWindow.ReadFilePreview C# (CSharp) Method

ReadFilePreview() private method

private ReadFilePreview ( string filePath, Encoding enc ) : string
filePath string
enc System.Text.Encoding
return string
        private string ReadFilePreview(string filePath, Encoding enc) {
            StringBuilder sb = new StringBuilder();
            using (var sr = new StreamReader(filePath, enc, detectEncodingFromByteOrderMarks: true)) {
                int readCount = 0;
                while (readCount < MaxPreviewLines) {
                    string read = sr.ReadLine();
                    if (read == null) {
                        break;
                    }
                    sb.AppendLine(read);
                    readCount++;
                }
            }
            return sb.ToString();
        }