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

  • Home
  • SEARCH
  • 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 8913603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:30:11+00:00 2026-06-15T04:30:11+00:00

how do i read the second line of text in visual studio 2012 c#

  • 0

how do i read the second line of text in visual studio 2012 c#

         the txt file

         user123
         **12345**
         asdfd

i want to get the second line in one button1_click and show it to textblock2

i did try learn from here
How do I read a specified line in a text file?

and here
How to skip first line and start reading file from second line in C#

but no one of these works because theres difference i couldnt apply in my code

any help?

=================================================================================
sorry to confusing you all
actually im really lacking experience in programming and i hardly know how to use it
right now im using vs2012 in windows8 , is that mean i was coding in winrt?

btw , i appreciate all your help and successfully applying answer to my code
this is the actual code

        var file = await ApplicationData.Current.LocalFolder.GetFileAsync(tb1.Text+".txt");
        var line = await FileIO.ReadLinesAsync(file);
        if (tb2.Text == line[2])
        {
            tb3.Text = (line[1]);
        }
  • 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-06-15T04:30:12+00:00Added an answer on June 15, 2026 at 4:30 am
    var desiredText = File.ReadLines("C:\myfile.txt").ElementAt(1);
    

    File.ReadLines() returns an IEnumerable<String> of the lines in a file. The index of the second line is 1. See this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to read a file one line at each second using timer. Once
This code will read a line from a text file: set file = CreateObject(Scripting.FileSystemObject).OpenTextFile(c:\number.txt,
I want to read a .txt file in c# and filter a line out
I want to open a text file (see below), read the first int in
I'm trying to read each line from a text file using batch. The lines
I want to remove a line from my file (specifically the second line) so
I'm trying to read a text file line-by line. I added a condition where
Suppose I have a text file with data like below, I want to read
I am a newbie in Visual Studio (C#). I want to store a text
I have been doing a project where I want to read a text file

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.