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 6703867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:13:20+00:00 2026-05-26T07:13:20+00:00

fairly new to C# here… …What I’m trying to do is parse a bunch

  • 0

fairly new to C# here…

…What I’m trying to do is parse a bunch of text to a webpage from a .txt file uploaded to memory.

Here’s what the .txt file looks like


.RES B7=121
.RES C12=554
.RES VMAX=4.7μV

Again, it goes on like this for another 50 or so .RES’…
I’ve successfully got it to parse, but not in the desired format…
Here’s how I want it to look on the webpage



B7.........121
C12.........554
VMAX.........4.7μV

all inside of a hidden panel with id=”outpt”… which is currently set to visible=”false”


Here’s the code i’m using in my C# Page

namespace Sdefault
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void btnUpld_Click(object sender, EventArgs e)
        {
            Stream theStream = file1.PostedFile.InputStream; //uploads .txt file     to memory for parse

            using (StreamReader sr = new StreamReader(theStream))
            {
                string tba;
                while ((tba = sr.ReadLine()) != null)
                {

                    string[] tmpArray = tba.Split(Convert.ToChar("=")); //Splits ".RES B7=121" to "B7"... but for some reason, It prints it as
                                                                        //".RES B7.RES C12.RES VMAX"... I would ultimately desire it to be printed as shown above




                    Response.Write(tmpArray[0].ToString());
                    var.Text = tba;
                    outpt.Visible = true;
                }

            }

        }
    }

}

Any pointers in which direction I should go with this?

  • 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-26T07:13:20+00:00Added an answer on May 26, 2026 at 7:13 am
    // Open the file for reading
    using (StreamReader reader = new StreamReader((Stream)file1.PostedFile.InputStream))
    {
      // as long as we have content to read, continue reading
      while (reader.Peek() > 0)
      {
        // split the line by the equal sign. so, e.g. if:
        //   ReadLine() = .RES B7=121
        // then
        //   parts[0] = ".RES b7";
        //   parts[1] = "121";
        String[] parts = reader.ReadLine().split(new[]{ '=' });
    
        // Make the values a bit more bullet-proof (in cases where the line may
        // have not split correctly, or we won't have any content, we default
        // to a String.Empty)
        // We also Substring the left hand value to "skip past" the ".RES" portion.
        // Normally I would hard-code the 5 value, but I used ".RES ".Length to
        // outline what we're actually cutting out.
        String leftHand = parts.Length > 0 ? parts[0].Substring(".RES ".Length) : String.Empty;
        String rightHand = parts.Length > 1 ? parts[1] : String.Empty;
    
        // output will now contain the line you're looking for. Use it as you wish
        String output = String.Format("<label>{0}</label><input type=\"text\" value=\"{1}\" />", leftHand, rightHand);
      }
    
      // Don't forget to close the stream when you're done.
      reader.Close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new to Netbeans Platform. Here is what I'm trying to do, I
fairly new iPhone developer here. Building an app to send RS232 commands to a
I fairly new to JQuery and perhaps trying to achieve something that might be
I'm fairly new to ASP.NET and trying to learn how things are done. I
I am fairly new to Emacs and I have been trying to figure out
I'm fairly new at programming, but I've wondered how shell text editors such as
I am fairly new to Java so I am probably missing something fundamental here
I am fairly new to WPF and am probably missing something simple here. If
I am fairly new to NodeJS and to JavaScript in general. Here is my
I'm still fairly new to rails so I'm not sure what I'm missing here.

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.