Hello :
How can I by programming, change the encoding of the text file,, I want to open a text file but I couldn't because it's encode in ANSI I want to change it to another encoding type???
Thanks
Hello :
How can I by programming, change the encoding of the text file,, I want to open a text file but I couldn't because it's encode in ANSI I want to change it to another encoding type???
Thanks
I think you need more details to describe your exact problem as I don't believe the obvious answer is really your question. The obvious answer being: Open up the text file in ANSI, encode the data and write to output file.
Firstly you should open Up your ANSI file with Its encoding then store in a String or something like that then apply your Encoding algorithm to it.
Hello :
How can I by programming, change the encoding of the text file,, I want to open a text file but I couldn't because it's encode in ANSI I want to change it to another encoding type???
Thanks
Hello,
try this code, it converts txt files from encoding1 to encoding2
in the following code i am converting any encoding to CodePage1256
using (Stream fileStream = new FileStream(file.FileLocation, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
using (Stream destStream = new FileStream(destinationPath, FileMode.Create, FileAccess.Write,
FileShare.ReadWrite))
{
using (var reader = new BinaryReader(fileStream))
{
using (var writer = new BinaryWriter(destStream, Encoding.GetEncoding(1256)))
{
var srcBytes = new byte[fileStream.Length];
reader.Read(srcBytes, 0, srcBytes.Length);
writer.Write(srcBytes);
}
}
}
}
Good Luck
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.