Problem to read a line from .txt file RRS feed

  • Question

  • Hello!

    I have a problem to read a line from a .txt file. This is the text file: download textfile

    When looking at the line in the text file it looks like below. Download the file and look in the actual file and the below is on the same line. When you click on the link. The text is on different rows.

    "Address:andrén            sörgårdsvägen 197"

    I want to replace the hidden characters so: sörgårdsvägen 197 actually is on the SAME line when reading that line from the textfile.

    I beleive this html code is in the textfile which is hidden which causes a new line: <br>

    The thing is that "sörgårdsvägen 197" is not on the SAME line in the textfile when reading the line with the below code. So it has to be some hidden characters like: \n or \r or \r\n but when trying to replace those chars with an empty string it doesn't help.

    So it is on the SAME line in the text file but not when reading the file line by line like the code below.

    //Read the file
    StreamReader reader = null; FileStream fs = null; String getline = "";
    fs = new FileStream("C:/testing1.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); reader = new StreamReader(fs);
    while (reader.Peek() >= 0)
        getline = reader.ReadLine().ToLower().Replace("\r\n", "").Replace("\r", "").Replace("\n", "");;
    reader.Close(); fs.Close();

    • Edited by Silvers11 Monday, August 13, 2018 7:06 PM
    Monday, August 13, 2018 6:51 PM


All replies