I have a strange problem. I read a text file and then split it using \ n as a delimiter. I noticed that the dividing lines contain "\ r" at the end. So I'm trying to remove it, I tried to do it with String.Replace, but with no luck. Here is my code:
string fileOutput = File.ReadAllText(location);
SettingsManager.proxies.Clear();
foreach (string line in fileOutput.Split('\n'))
{
string cleanLine = line;
if (cleanLine.Contains("\r")) cleanLine.Replace("\r", "");
SettingsManager.proxies.Add(cleanLine);
}
EDIT: after looking at the code for 1 minute, I found that I did not assign the replaced value to the original string.
cleanLine.Replace("\r","");
I had to assign cleanLine to cleanLine.Replace ();
cleanLine = cleanLine.Replace("\r","");
source
share