hi i have trouble understand system.io .
i read through the msdn, but ....still dun undertsnd how to use
i know it can use to write and read from a text file using stream writer or reader
the read code is like this but i cant understand

StreamReader reader=new  StreamReader(winDir + "\\system.ini");
        try   
        {    
            do
            {
                addListItem(reader.ReadLine());
            }   
            while(reader.Peek() != -1);
        }      
         
        catch 
        { 
            addListItem("File is empty");}

        finally
        {
            reader.Close();
        }

Exactly what is the question.?

the code you posted creates a stream reader object and uses it to add each line of the system.ini settings file to a list.

What is your goal? Elaborate.

Check the reader stream and the writer stream, msdn has examples for using both

Hie,

This one is just a simple program that creates a StreamReader object for adding a text into list by reading settings.ini file. Program is using Do While loop for reading.

That means, code in Do block will run minimum one time and terminating expression is "reader.peek() != -1". Peek method returns the next available char else it will be -1.

As i told you, DO block wil run minimum once, If file is empty then it will throw a expection that will be catched by CATCH block.

If still cant get it. Just post here :)

Regards,
PuneetK

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.