Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hey guys, i'm just wondering is there a way to read in a UTF8 encoded file and convert it to plain text. I can read the file in alright but no matter what I do I can't convert it to plain text. Any help very much apreciated thanks.
Posted

1 solution

Here is the solution.

C#
FileStream stream = new FileStream( fileName, System.IO.FileMode.Open );
BinaryReader reader = new BinaryReader( stream );
string text = Encoding.UTF8.GetString( reader.ReadBytes( (int)reader.BaseStream.Length ) );
 
Share this answer
 
Comments
frostcox 23-Nov-12 3:50am    
Hey thank you very much, the file must be encrypted as when I use the GEtEncoding it says UTF8 but when I decode it is still un-readable. Thanks for your help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900