Reading and Writing textfile with Encoding

To read and write textfiles, in Dynamics NAV, with special Encoding, you have to use the StreamReader or StreamWriter class, and the Encoding class from .NET.
With this you don’t need your OEM2ANSI conversion functions anymore.
Note that XML Port has encoding built in, and File in the latest versions also offers some simple Encoding options.

Read from file

If you want to read a textfile , you use the .NET StreamReader class.
In this example I am assuming UTF8 encoding.
You have to know that encoding of the file beforehand!