I am trying to save data from web searches using selenium web driver and C#, it all works ok, but when the text is saved some characters seems to have a wrong encoding, here is the snippet of my code:
        using (System.IO.StreamWriter file = new System.IO.StreamWriter(@fileName, true))
        for (int i = 1; i <= 10; i++)
        {
            String xpath = "/html/body/div[5]/div[2]/div/div[6]/div/div[3]/div/div[2]/div/ol/li[" + i + "]/div"; // google
            String element = driver.FindElement(By.XPath(xpath)).Text;               
            element.Replace(",", " ");
            element = '"' + " " + element + " " + '"'+",";
            {
some of the weird characters found in the file look like these ones:
› ... ›
any help would be much appreciated :)
############# resolution belowfound the solution to this issue by using:
        string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
        using (System.IO.StreamWriter file = new System.IO.StreamWriter(@fileName, true, UnicodeEncoding.UTF8))
 
    