I have a method in a .Net Core 6 Class Library that reads a CSV file that has 1252 encoding:
public void checkCsv(string pathCsvFile) {
int codeEncoding = 1252;
string line1 = "";
foreach (var line in File.ReadAllLines(pathCsvFile, System.Text.Encoding.GetEncoding(codeEncoding))) {
line1 = line;
break;
}
// some more code here...
}
For some reason, if I call this method from a Winforms app (.Net Core 6), it works flawlessly. But if I call it from a WPF app (.Net Core 6), it fails with an exception:
No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Any help?