Quantcast
Viewing latest article 1
Browse Latest Browse All 10

How to read data from a text file in c#?

string filePath = @”c:\Sample.txt”;

string line,SNo=” “;

if (File.Exists(filePath))

{

StreamReader file = null;

try

{

file = new StreamReader(filePath);

while ((line = file.ReadLine()) != null)

{

Console.WriteLine(line);

//SNo = line.Substring(0,3);

}

}

finally

{

if (file != null)

file.Close();

}

}

Udhaya


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing latest article 1
Browse Latest Browse All 10

Trending Articles