Data files?

Is it possible to use datafiles in C#

if so how

i have a project to do in C# and Data files would help bunches.


Answer this question

Data files?

  • bendodge

    Hmm, honestly I don't know... my phone bills are pretty scary, but I cannot think of anybody whose bills would take so much memory ;)

    Ok, if it's just to start learning about files, you may want to start with the easy stuff... which is in the System.IO namespace. For instance, look up StreamReader and StreamWriter, that will allow you to read and write a text file. I'm not providing any example for the simple reason that there are some good ones on MSDN. There is also an nice How-To section here regarding basic file handling.

    I think this should set you going... don't hesitate to ask if you need more info.

    Happy programming
    --mc


  • Jamez05

    Mario Cossi wrote:

    Well, .NET has a number of different classes that will help handling specific type of files.

    To handle binary data files, look at BinaryReader and BinaryWriter. They provide methods to read, write, seek...

    To handle text files (they are data files, after all), look at StreamReader and StreamWriter, but you might also be interested in TextReader, StringReader etc.

    To handle XML files, (guess ), XmlReader and XmlWriter, and pretty much anything else in the System.Xml namespace.

    But also, you might want to give a glance at the Serialization concepts as they make formatting and parsing data much easier.

    Finally, there are some files that can be handled directly as if they were DataSets...

    As you see you have plenty of choices, but without an example of what you are really trying to do it's impossible to be more specific (I guess one could write a book just covering these subjects).

    Hope this helps
    --mc



    well i have to write a program to compare celphone contracts (its a 1st year university project-introduction to programming) and instead of creating say 12objects(3 for each Service Provider)each time the program runs, i want to write them to a datafile(s)... and have the user select teh SP then only create the objects for that spesific SP... also we are given a phonebill(to test it with) ... i want the conver the bill to a datafile(from text) to make it easier to work with(fields such as duration, cost and such) and THIS file is quite large, creating that manny objects would use up large amounts of memory.
    the probleme is the handbook proscribed does not contain any such information(on datafiles) as it will not be covered this semseter.

  • Ralph Trickey

    Mario Cossi wrote:

    Could you be a little more specific What do you mean by data files exactly

    --mc


    well every thing... i want to use them... but cant find any reffrence to how....


  • Reginald

    Well, the next logical step would be to use a binary file, through a BinaryReader and BinaryWriter (see the doc). These will allow you to read and write arrays of bytes from a file, and also to move to a specified position in the file using the Seek method. You will need to determine a fixed size for your records, and provide functions to convert your data to and from an array of bytes.

    This approach will allow you to have the minimum impact on memory, but it's a lot of work, and error prone. Also, it's not adaptable at all.

    I start to suspect you are really looking for information about dataBASEs, not data files... is that so

    --mc


  • Jinno

    erm... i know how to work textfiles (streamreader and -writer and such) bu ti just want to know how to use the datafiles, how to read and write the records and such. and i wich to use datafiles to make the program more addaptable.

  • ServerGirl

    Could you be a little more specific What do you mean by data files exactly

    --mc


  • Abdulelah Dandachi

    Well, .NET has a number of different classes that will help handling specific type of files.

    To handle binary data files, look at BinaryReader and BinaryWriter. They provide methods to read, write, seek...

    To handle text files (they are data files, after all), look at StreamReader and StreamWriter, but you might also be interested in TextReader, StringReader etc.

    To handle XML files, (guess ), XmlReader and XmlWriter, and pretty much anything else in the System.Xml namespace.

    But also, you might want to give a glance at the Serialization concepts as they make formatting and parsing data much easier.

    Finally, there are some files that can be handled directly as if they were DataSets...

    As you see you have plenty of choices, but without an example of what you are really trying to do it's impossible to be more specific (I guess one could write a book just covering these subjects).

    Hope this helps
    --mc


  • Data files?