Hi
The below code is to read the random line from Test.txt
Hope with some modifications this can be helpful and solve your issue.
Code:
TextReader tr = new StreamReader(Request.PhysicalApplicationPath + "Test.txt");
int nooflines = 0;
while (tr.ReadLine()!=null)
{
nooflines++;
}
Random randnum = new Random();
tr.Close();
tr = new StreamReader(Request.PhysicalApplicationPath + "Test.txt");
int rnd = randnum.Next(0,nooflines);
int i=0;
string temp;
while (( temp = tr.ReadLine()) !=null)
{
if (i==rnd)
{
ShowMsg.Text=temp;
break;
}
i++;
}
tr.Close();
Vivek Shah