What's new

Closed Open multi lined text file and read only an specific line in it. and send the value to a textbox

Status
Not open for further replies.

mac

Addict
Joined
Jan 12, 2015
Posts
5
Reaction
0
Points
64
Age
34
-2You do not have permission to view the full content of this post. Log in or register now.


I have created a code that generates a multi lined text file.

What i would like to achieve is read only a specific line and send that value to a specific textbox.

Below is my form :

wX3YN.png

My Text file sample and What i want to achieve please see below :

pBnOE.png

Please see below my code :


var open = new OpenFileDialog();

open.Title = "Open File";

open.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";

if (open.ShowDialog() == DialogResult.OK)
{

FilePathLB.Text = open.InitialDirectory + open.FileName;

StreamReader read = new StreamReader(File.OpenRead(open.FileName));

//X1TB.Text = File.ReadLines(open.FileName).Skip(1).Take(1).First();
//X1TB.Text = read.ReadLine();
X1TB.Text = read.ReadLine();




read.Dispose();
}

Salamat sa mga tutulong.
 

Attachments

Status
Not open for further replies.
Back
Top