tags:

views:

66

answers:

3

Sometimes in reading data involving many names and figures reading line by line needs some serious concatenation work , is there any method that would allow me to read a specific data type? like the good old fscanf in C?

Thanks

Sara

+1  A: 

I don't know if this is exactly what you are looking for, but the FileHelpers library has many utilities to help with reading fixed length and delimited text files.

From the site:

You can strong type your flat file (fixed or delimited) simply describing a class that maps to each record and later read/write your file as an strong typed .NET array

If what you are looking for is getting strongly typed objects from files, you should look at serialization and deserialization in the .net framework. These allow you to save object state into a file and read them back at a later time.

Oded
I will give it a try thx !
Sara Ste.
+1  A: 

You could use BinaryReader to read the data from the file, assuming the data is written out in binary form. For example, an Int32 would be written out as 4 bytes ie. the binary representation and not the text representation of the integer.

The usefullness of BinaryReader would depend on the control you have of the code generating the file, ie. can you write the data out using a BinaryWriter and of course how human readable you need the file to be.

Chris Taylor
I thought Of That but i need to use text filesThanks Alot
Sara Ste.
+1  A: 

The System.IO namespace got everything you need.

Will Marcouiller
Not that great of a help, uh?
devoured elysium
@devoured elysium: Chris Taylor already gave a very good answer which I upvoted. If Sara Ste wishes to get further information, what else than guide her to the namespace directly? There she will able to find everything she needs, and even be able to choose according to her needs and situation.
Will Marcouiller
I've Already went through the System.IO classes nothing would do the job
Sara Ste.