TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sainath Reddy
NA
101
1.5k
Reading a text file from local and paste in a label
Aug 3 2019 1:29 AM
Hi friend i have one requiremnt can you help me
we need to pick up a txt file from our local system ssuppose c:\textfile,.txt
in txt file if we have 4 lines
text 1
text 2
text 3
text4
i need to need pick only the 2and 3 lines and need to paste it in the web application specific textboxs
text2 --textbox 1
text3 --textbox 2
sample code i have tried in console
can any one help me through web applicaton the same thing
using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.IO;
namespace
textfilereading {
class
Program {
static
void
Main(
string
[] args) {
//Load our text file
TextReader tr =
new
StreamReader(@
"G:\tetfile.txt"
);
//How many lines should be loaded?
int
NumberOfLines = 15;
//Make our array for each line
string
[] ListLines =
new
string
[NumberOfLines];
//Read the number of lines and put them in the array
for
(
int
i = 1; i < NumberOfLines; i++) {
ListLines[i] = tr.ReadLine();
}
//This will write the 5th line into the console
Console.WriteLine(ListLines[5]);
//This will write the 1st line into the console
Console.WriteLine(ListLines[1]);
Console.ReadLine();
// close the stream
tr.Close();
}
}
}
Reply
Answers (
1
)
Asp.net project with web api
How to get the value from aspx script tag to .cs