Encoding Multiply Files to UTF8 without BOM with C#
Console.WriteLine("put bellow the path of files:");
string path = Console.ReadLine();
File.SetAttributes(path, FileAttributes.Normal);
var files = Directory.GetFiles(path);
var utf8WithoutBOM = new System.Text.UTF8Encoding(false);
foreach (var file in files)
{
File.SetAttributes(file, FileAttributes.Normal);
var content = File.ReadAllLines(file);
Console.WriteLine("Converting the file '"+ file + "'...");
System.IO.File.WriteAllLines(file, content,utf8WithoutBOM);
Console.WriteLine(file + " Converted");
}
Console.WriteLine("Done.");
Written by Samuel Diogo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Utf8
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#