I need to write an application which uses data stored in a .dat file created by another application. Basically the app which creates the .dat is a freeware app which collects info from an online game and stores the info. It also does some processing of the data. What i am planning to do is create a team tool which makes use of the stored data and do some further processing using our personal game knowledge.
Now i know what are the possible contents of the .dat file but not sure how i can read the data from it. I would appreciate any help on how to extract all the data from this .dat file. Not asking to be spoon fed with all code but step wise instructions on how to go about this would be really appreciated.
If you need any further info please do ask
Regards
EDIT: Opening the .dat file in wordpad i get the following:
https://i.sstatic.net/kZ1OH.jpg
If the file is a text file where you would like to parse strings, you can use a StreamReader
, like this:
using (var textFile = System.IO.File.OpenText("yourfile.dat"))
{
string line = null;
while ((line = textFile.ReadLine()) != null)
{
// Parse line.
}
}
If you need to parse a binary format, you can use a BinaryReader
, like this:
using (var dataFile = new System.IO.BinaryReader(System.IO.File.OpenRead("yourfile.dat")))
{
try
{
// Parse your data file according to the known format.
dataFile.ReadBoolean();
dataFile.ReadInt32();
// ...and so on.
}
catch(System.IO.EndOfStreamException e)
{
// Handle trying to read past the end of the stream
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With