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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:36:57+00:00 2026-05-25T15:36:57+00:00

I have a file I am bringing into a RTB. Let’s say it looks

  • 0

I have a file I am bringing into a RTB.

Let’s say it looks something like this:

// Some Title
// Some Author
// Created on
// Created by
//

Format:
 "Text Length" : 500 lines
 "Page Length" : 20 pages

Component: 123456
 "Name" : Little Red Riding Hood
 "Body Length" : 13515 lines
 ........etc // can have any number of lines under 'Component: 123456'

Component: abcd
 "Name" : Some other Text
 "Body Length" : 12 lines
 ........etc // can have any number of lines under 'Component: abcd'



... etc, etc  // This can occur thousands of times as this file has an unset length.

Now what I would like to do is store everything from Component: 123456 until it reaches the next Component (which happens to be abcd) and store everything into the List<string> position 0. The next one will be in position 1.. and so on until the entire file is read.

Does anyone know how to do this? — I don’t necessarily need to use List<string>

  • 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-25T15:36:58+00:00Added an answer on May 25, 2026 at 3:36 pm

    Well, you could do something like:

    // I'm assuming you're using .NET 4
    var lines = File.ReadLines(filename);
    
    var components = new List<string>();
    StringBuilder builder = new StringBuilder();
    foreach (var line in lines)
    {
        if (line.StartsWith("Component: "))
        {
            components.Add(builder.ToString());
            builder = new StringBuilder();
        }        
        builder.Append(line);
        builder.Append("\r\n");
    }
    
    // Get the trailing component
    components.Add(builder.ToString());
    
    // Get rid of the first non-component part
    components.RemoveAt(0);
    

    (It’s more efficient to ignore the bits before the first component, but it makes the code more complicated.)

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

Sidebar

Related Questions

I have file which contains some data, like this 2011-01-02 100100 1 2011-01-02 100200
Say I have file A, in middle of which have a tag string #INSERT_HERE#.
I have a file which is an XML representation of some data that is
I have a rails-backbone project that generates jst.ejs templates. I'd like to include some
I have this following code for bringing page attachments to the user: private void
I have been given the task of bringing three legacy systems together into one
I have a very simple photo uploader which needs some bringing up to speed
I have file with jspx extension i write javascript like function isNumber(inputId){ var value
I have file sample.xml in my project set as content. I am running this
i have a php script like this: <?php $likes = 'https://graph.facebook.com/google'; $fb = file_get_contents($likes);

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.