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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:33:31+00:00 2026-05-13T09:33:31+00:00

I have a few multimillion lined text files located in a directory, I want

  • 0

I have a few multimillion lined text files located in a directory, I want to read line by line and replace “|” with “\” and then write out the line to a new file. This code might work just fine but I’m not seeing any resulting text file, or it might be I’m just be impatient.

{
        string startingdir = @"K:\qload";
        string dest = @"K:\D\ho\jlg\load\dest";
        string[] files = Directory.GetFiles(startingdir, "*.txt");

        foreach (string file in files)
        {
            StringBuilder sb = new StringBuilder();
            using (FileStream fs = new FileStream(file, FileMode.Open))
            using (StreamReader rdr = new StreamReader(fs))
            {
                while (!rdr.EndOfStream)
                {
                    string begdocfile = rdr.ReadLine();
                    string replacementwork = docfile.Replace("|", "\\");
                    sb.AppendLine(replacementwork);
                    FileInfo file_info = new FileInfo(file);
                    string outputfilename = file_info.Name;
                    using (FileStream fs2 = new FileStream(dest + outputfilename, FileMode.Append))
                    using (StreamWriter writer = new StreamWriter(fs2))
                    {
                        writer.WriteLine(replacementwork);
                    }
                }
            }
        }
    }

DUHHHHH Thanks to everyone.

Id10t error.

  • 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-13T09:33:31+00:00Added an answer on May 13, 2026 at 9:33 am

    Use Path.Combine(dest, outputfilename), from your code it looks like you’re writing to the file K:\D\ho\jlg\load\destouputfilename.txt

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

Sidebar

Related Questions

I have few lines of text in TextView. I want to apply italics to
I have few nested DIVs at page. I want to add event only for
I have few text and excel file, from which I need to import data
I have few questions, I want to show the alert window on my Update
I have few jar files which I am not getting from any repositories.I have
I have few 'so' files that I need to load in maven java project
I have few custom controls (image views) added programmatically to table cell. I want
i have few variables like this: self.lamp_1 self.lamp_2 self.lamp_3 self.lamp_4 and now i want
I have few TabPages and each contains rich text box. How can I access
i have few textfields in my php form. i want to handle the keypress

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.