Click here to Skip to main content
15,037,420 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

can anyone help me please?
I want to read the 8th line of a text file and put it in textbox1.
I knew the code of reading.
This code is to read the text file:
FileStream^ fs = File::OpenRead( path );

But how to read the 8th line and convert it to string?
Thanks in advance.

Retagged as C++/CLI
Updated 1-Jan-11 23:04pm

1 solution

FileStream^ fs = File::OpenRead( path );
StreamReader^ sr = gcnew StreamReader( fs );
int count = 0;
String^ myLine;
while ( sr->Peek() >= 0 && count<8)
    myLine = sr->ReadLine();

That should do it!

Seif Hatem 1-Jan-11 10:42am
Thanks Really thanks I SPENT 3 Days searching
Manfred Rudolf Bihy 1-Jan-11 10:51am
Glad to help! You got that textBox1->Text = myLine thing figured out?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900