-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
I have recently upgraded .NET Core 3.1 SDK to version v3.1.200 with Visual Studio Community 2019 and I'm building and application for Raspberry Pi where one part of it reads the content on specific file from filesystem and parses it (very simple).
Some days ago (don't remember previous core version) but it was working correctly. Now suddently stopped. The problem is with searching of a specific substring position in the file using string.IndexOf method. It always gets me return value of -1 for whatever string I search for, even with only char inside. But when I search for last char of '=' it gives me proper index result. (But I want to search for "t=" substring here anyway)..
string sensorStatus = System.IO.File.ReadAllText(path);
int index = sensorStatus.IndexOf("t=") + 2;
string temperatureString = sensorStatus.Substring(index, 5);
double result = Convert.ToDouble(temperatureString) / 1000;
File content:
57 01 4b 46 7f ff 0c 10 38 : crc=38 YES
57 01 4b 46 7f ff 0c 10 38 t=21437
The same file content (whole file) copied and run in Windows yield with proper parsed value.
Am I missing something here? What is even funnier the same code before worked but can't recall exact framework versions etc..