0

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();
        }
5
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by puneetkay
0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.