Hello,
You could use the File.ReadAllLines method to get all the lines in the file as an array first. Then use the method of step changer traversal to read 500 rows at a time and display.
Please refer to the following documentation and sample code:
int step = 0;
int loglines = 500;
private void OnReadLogClicked(object sender, EventArgs e)
{
StringBuilder myStringBuilder = new StringBuilder();
var path = "your log file path";
var strings = File.ReadAllLines(path);
if (strings.Length >= loglines)
{
foreach (var str in strings.Skip(step).Take(loglines))
{
myStringBuilder.AppendLine(str);
test_label.Text = myStringBuilder.ToString();
}
step += loglines;
loglines += 500;
}
else
{
foreach (var str in strings.Skip(step))
{
myStringBuilder.AppendLine(str);
test_label.Text = myStringBuilder.ToString();
}
}
}
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.