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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:04:09+00:00 2026-05-14T04:04:09+00:00

Hey everybody, this is what I have going on. I have two text files.

  • 0

Hey everybody, this is what I have going on. I have two text files. Umm lets call one A.txt and B.txt.

A.txt is a config file that contains a bunch of folder names, only 1 listing per folder.

B.txt is a directory listing that contains folders names and sizes. But B contains a bunch of listing not just 1 entry.

What I need is if B, contains A. Take all lines in B that contain A and write it out as A|B|B|B ect….

So example:

A.txt:
Apple
Orange
Pear
XBSj
HEROE

B.txt:
Apple|3123123
Apple|3434
Orange|99999999
Orange|1234544
Pear|11
Pear|12
XBSJ|43949
XBSJ|43933

Result.txt:
Apple|3123123|3434
Orange|99999999|1234544
Pear|11|12
XBSJ|43949|43933

This is what I had but it’s not really doing what I needed.

string[] combineconfig = File.ReadAllLines(@"C:\a.txt");
        foreach (string ccline in combineconfig)
        {
            string[] readlines = File.ReadAllLines(@"C:\b.txt");
            if (readlines.Contains(ccline))
            {
                foreach (string rdlines in readlines)
                {
                    string[] pslines = rdlines.Split('|');
                    File.AppendAllText(@"C:\result.txt", ccline + '|' + pslines[0]);
                }
            }

I know realize it’s not going to find the first “if” because it reads the entire line and cant find it. But i still believe my output file will not contain what I need.

  • 1 1 Answer
  • 2 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-14T04:04:09+00:00Added an answer on May 14, 2026 at 4:04 am

    Assuming you’re using .NET 3.5 (so can use LINQ), try this:

    string[] configLines = File.ReadAllLines("a.txt");
    var dataLines = from line in File.ReadAllLines("b.txt")
                    let split = line.Split('|')
                    select new { Key = split[0], Value = split[1] };
    var lookup = dataLines.ToLookup(x => x.Key, x => x.Value);
    
    using (TextWriter writer = File.CreateText("result.txt"))
    {
        foreach (string key in configLines)
        {
            string[] values = lookup[key].ToArray();
            if (values.Length > 0)
            {
                writer.WriteLine("{0}|{1}", key, string.Join("|", values));
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all i have two JFrames one is my main login frame, user enters
hey guys having this really simple problem but cant seem to figure out have
hey guys I have the follow code in js: $(document).ready(function(){ $(.replyLink).click(function(){ $(#form-to-+this.id).html(htmlForm()).toggle(500); return false;
Hey guys here is my php: $x = array(one, two, three); foreach ($x as
Hey everybody! When I build this, i get a warning on the objectForKey... the
Hey everybody. So, I'm creating this kind of a social network script for a
Hey everybody, I'm very confused about how to use two different Cell Types in
Hey everybody, Im really confused about this problem. Ill try to describe it: The
hey guys I have two divs- with id=form1 which is inline and the other
Hey i have been looking around and i cant find a way to get

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.