vb.netarabic

How to read a text file containing Arabic chars in VB.Net 2005?


I'm using MS Visual Studio 2005 VB.NET. I have a text file that includes English characters and Arabic characters as well. These characters are mixed with each others.

I have to read this file chars by chars including even the spaces. Though I used the following code but it didn't get me the right result:

Dim objReader As New System.IO.StreamReader(pfile)
Dim strAll As String
strAll = objReader.ReadToEnd

In this code I read all the content of the file; But unfortunately the length of the Varaible strALL was less than the number of chars in the file.

How can I read this file properly in order to store it in a database correctly?


Solution

  • You need to specify the encoding:

    data = File.ReadAllText(path, Encoding.GetEncoding("windows-1256"))