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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:57:09+00:00 2026-05-20T05:57:09+00:00

There is probably no other way to do this, but is there a way

  • 0

There is probably no other way to do this, but is there a way to append the contents of one text file into another text file, while clearing the first after the move?

The only way I know is to just use a reader and writer, which seems inefficient for large files…

Thanks!

  • 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-20T05:57:09+00:00Added an answer on May 20, 2026 at 5:57 am

    No, I don’t think there’s anything which does this.

    If the two files use the same encoding and you don’t need to verify that they’re valid, you can treat them as binary files, e.g.

    using (Stream input = File.OpenRead("file1.txt"))
    using (Stream output = new FileStream("file2.txt", FileMode.Append,
                                          FileAccess.Write, FileShare.None))
    {
        input.CopyTo(output); // Using .NET 4
    }
    File.Delete("file1.txt");
    

    Note that if file1.txt contains a byte order mark, you should skip past this first to avoid having it in the middle of file2.txt.

    If you’re not using .NET 4 you can write your own equivalent of Stream.CopyTo… even with an extension method to make the hand-over seamless:

    public static class StreamExtensions
    {
        public static void CopyTo(this Stream input, Stream output)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            byte[] buffer = new byte[8192];
            int bytesRead;
            while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0)
            {
                output.Write(buffer, 0, bytesRead);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is probably a simple answer for this, but I couldn't find one, so
There is probably an obvious answer to this question, but I am having one
There is probably already an answer for this somewhere, but I must not be
First of all there is probably a question like this already but i couldn't
Had another thread regarding this but it wasn't resolved probably because I wasn't very
There is probably a quite logical explanation to this, but I have a question.
I know that probably there is no concept of scope for macros, but please
i've spent some time searching and there is probably is an easy way to
I'm new to the OOP paradigm, so there's probably a simple explanation for this
am [writing reading] from a plain text file usernames and passwords, but its an

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.