Hello, utf-8 characters problem in Result.txt
using System; using System.Linq; using System.Text; using HtmlAgilityPack; namespace DemoHtmlAgilityPack { class Program { static StringBuilder text = new StringBuilder(); private static void Main(string[] args) { var client = new System.Net.WebClient(); client.Encoding = Encoding.UTF8; var filename = System.IO.Path.GetTempFileName(); string s = client.DownloadString("http://fastandclever.ru"); System.IO.File.WriteAllText(@"C:\TEST\page.html", s); HtmlDocument doc = new HtmlDocument(); doc.Load(@"C:\TEST\page.html"); var root = doc.DocumentNode; var a_nodes = root.Descendants("a").ToList(); Console.WriteLine(s); Console.ReadKey(); foreach (var a_node in a_nodes) { text.Append("LINK: " + a_node.GetAttributeValue("href", "") + "\nTEXT: " + a_node.InnerText + "\n\n"); } System.IO.File.WriteAllText(@"C:\TEST\Result.txt", text.ToString(), Encoding.UTF8); } } }
I try to get utf-8 characters encoding, but without luck. In cmd russian characters show properly, but not in Result.txt.
Thanks!