In the next steps, you use the Seek() method to reposition a file pointer so you can access a file from any location. The user will be prompted to enter a number representing a starting point to list the names in the Names.txt file. Names from that point forward will be listed, and then the user will be prompted for another selection. 1. Start a new program named AccessSomeNames that demonstrates how to access requested names from the Names.txt file you created in the CreateNameFile application. Searching a Sequential Text File using System; using static System.Console; using System.IO; class AccessSomeNames { static void Main() { FileStream file = new FileStream("Names.txt", FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(file);
Using the Seek() Method in C#
In the next steps, you use the Seek() method to reposition a file pointer so you can
access a file from any location. The user will be prompted to enter a number representing
a starting point to list the names in the Names.txt file. Names from that point
forward will be listed, and then the user will be prompted for another selection.
1. Start a new
to access requested names from the Names.txt file you created in the
CreateNameFile application.
Searching a Sequential Text File
using System;
using static System.Console;
using System.IO;
class AccessSomeNames
{
static void Main()
{
FileStream file = new FileStream("Names.txt",
FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(file);
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images