tags:

views:

138

answers:

2

how can access the binary data file(.DAT). i am using geonames API. can anyone help me?

A: 

Assuming you are using C# (from the tag), you can use BinaryReader class to read binary data. See How to read and write to a binary file:

FileStream fs = File.Open(Environment.CurrentDirectory + @"\settings.bin", FileMode.Open);
BinaryReader reader = new BinaryReader(fs);

long number = reader.ReadInt64();
byte[] bytes = reader.ReadBytes(3);
string s = reader.ReadString();

reader.Close();
fs.Close();

Console.WriteLine(number);
foreach (byte b in bytes)
{
 Console.Write("[{0}]", b);
}
Console.WriteLine();
Console.WriteLine(s);
eed3si9n
+1  A: 

If you are referring to the binary flat file format used by MaxMinds GeoLocation database, they offer some handy utility classes in C# and Java to access it.

http://www.maxmind.com/app/api

FlySwat