954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

change ANSI files encoding to utf-8

Hi i have a lot of ANSI encoded files in the same folder with different extensions and i want to convert all this files into utf-8 encoded files
so how can i do this in c#

Thank you

shandoosheri
Light Poster
42 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

Hey there,
In order to convert all of your ANSI encoded files to utf-8, you first need to get a list of your files in folder. After that you could use this code snippet..

StreamReader sr = new StreamReader(infile);  

StreamWriter sw = new StreamWriter(outfile, false, Encoding.UTF8);  
sw.WriteLine(sr.ReadToEnd);  

sw.Close();  
sr.Close();


Hope i helped. :)

Alexpap
Junior Poster
121 posts since Sep 2008
Reputation Points: 11
Solved Threads: 13
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: