Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7702945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:20:46+00:00 2026-05-31T23:20:46+00:00

I have created a streamReader, but the first ‘ReadLine()’ reads the 14th line in

  • 0

I have created a streamReader, but the first ‘ReadLine()’ reads the 14th line in the file, not the first, and I don’t know why this is.

My code is:

StreamReader reader = new StreamReader("argus-BIG.txt");  

//create array to hold data values
string[] branchData = new string[11];

//get 11 lines of branch data file and store in an array
for (int i = 0; i < 11; i++)
{
    branchData[i] = reader.ReadLine();
}            

//new instance of Branch Class
Branch tempBranch = new Branch();

//set branch values from branchData array
tempBranch.setBranchID(branchData[0]);
tempBranch.setBranchNickname(branchData[1]);
tempBranch.setBranchAddressNo(branchData[2]);
tempBranch.setBranchAddressStreet(branchData[3]);
tempBranch.setBranchAddressCity(branchData[4]);
tempBranch.setBranchAddressCountry(branchData[5]);
tempBranch.setBranchAddressPostCode(branchData[6]);            
tempBranch.setNearestBranch1(branchData[7]);
tempBranch.setNearestBranch2(branchData[8]);
tempBranch.setNearestBranch3(branchData[9]);
tempBranch.setNoCategories(Convert.ToInt32(branchData[10]));

I wrote a test app, which worked, then copied and pasted the code (which looked identical to me) back into my main program, and it worked. Thanks for your help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:20:47+00:00Added an answer on May 31, 2026 at 11:20 pm

    This should be working, and I am guessing that there is something else happening along the way. Once you open a reader, it moves down and must be reset if you want it back to reading from the top. Maybe your reference was left open elsewhere (but that is assuming that the posted code has something happening that was not posted), or used before this piece of code?

    However, you can always force the position to the top to verify this theory. If after this code, you still are at the 14th line, then it might be the file itself somehow?

    reader.DiscardBufferedData(); 
    reader.BaseStream.Seek(0, SeekOrigin.Begin); 
    reader.BaseStream.Position = 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a C# class file by using a XSD-file as an input.
I have code which uses the StreamReader to read HTML from a file, then
I know that variations on this question have been asked, but I've tried all
I have created a few little programs that export data to a text file
I have created a small classic asp file that I indend to call form
Have created a c++ implementation of the Hough transform for detecting lines in images.
I have created a template for Visual Studio 2008 and it currently shows up
I have created a custom dialog for Visual Studio Setup Project using the steps
I have created a PHP-script to update a web server that is live inside
I have created a UserControl that has a ListView in it. The ListView is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.