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();
}