How to read exact line from text file?

Hello again.I have one question:
(example) How I can read the 3rd line from a text file and transform the rezult to string



Answer this question

How to read exact line from text file?

  • KitTexas

    ok.thanks very very much.it works!!! I have another question: When I build a Nonrectangular Form without Title Bar, how I can resize the form (example: the right - bottom of Windows Media Player)

  • LirarenL

    sr.ReadLine() will return the result in string format, moreover don't forgot to close the streamreader object at the end

    sr.Close();


  • Paul Lowther

    Yes, you can do this by using the StreamReader Object.

    include the System.IO Namespace

    then

    StreamReader sr=new StreamReader("FilePath");
    sr.readline(); // reads first line
    sr.readline(); // reads second line
    sr.readline(); // reads third line

    check out for different read options according to your need.




  • Steffen Niekler

    please ask one question per thread, as far as this question, you can use the form hieght and width property to resize the form.



  • How to read exact line from text file?