s

C# create file with utf-8 encoding edit button Edit

author
Murugan Andezuthu Dharmaratnam | calendar 26 September 2020 | 0

If you want to create a sitemap for your website for SEO on google you need to create a sitemap.txt file with utf-8 encoding, In this post we will write C# code to create a text file with utf-8 encoding.

public ActionResult CreateSitemap()
{
    data = GetSiteMap()
    System.IO.File.WriteAllText(Server.MapPath("/sitemap.txt"), data, Encoding.UTF8);
    return Content("success");
}