Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. merge two files in a file

merge two files in a file

Scheduled Pinned Locked Moved C#
tutorialquestion
12 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W WhiteGirl23

    Hi, Can you tell me how to import a file in other file? thanks.

    C Offline
    C Offline
    Colin Angus Mackay
    wrote on last edited by
    #2

    Depends on the format of the file. Would you like to tell us more about these files?


    Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." Ready to Give up - Your help will be much appreciated. My website

    M 1 Reply Last reply
    0
    • W WhiteGirl23

      Hi, Can you tell me how to import a file in other file? thanks.

      B Offline
      B Offline
      BoneSoft
      wrote on last edited by
      #3

      What types of files? What do they contain? How do you want to 'merge' them? Are they text files and you want to append one to the other? Need more information.


      Try code model generation tools at BoneSoft.com.

      1 Reply Last reply
      0
      • W WhiteGirl23

        Hi, Can you tell me how to import a file in other file? thanks.

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #4

        Adding to what the others said, while it's true that, for example, merging two XML files is not as simple as appending one to the other, it's also true that it's not possible to append a file at all, no matter what, you need to read your two files, merge them in memory and write them back out, either overwriting one of your existing files, or to a new file.

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        1 Reply Last reply
        0
        • W WhiteGirl23

          Hi, Can you tell me how to import a file in other file? thanks.

          S Offline
          S Offline
          snorkie
          wrote on last edited by
          #5

          using (StreamWriter sw = new StreamWriter(@"C:\file1.txt") { using (StreamReader sr = new StreamReader(@"c:\file1.txt") { sw.Write(sr.ReadToEnd); } } Simple solution for text files... Hogan

          L 1 Reply Last reply
          0
          • S snorkie

            using (StreamWriter sw = new StreamWriter(@"C:\file1.txt") { using (StreamReader sr = new StreamReader(@"c:\file1.txt") { sw.Write(sr.ReadToEnd); } } Simple solution for text files... Hogan

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #6

            using (StreamReader sr = new StreamReader(@"c:\file2.txt") { File.AppendAllText(@"c:\file1.txt", sr.ReadToEnd()); } :)

            Luc Pattyn [My Articles] [Forum Guidelines]

            J 1 Reply Last reply
            0
            • L Luc Pattyn

              using (StreamReader sr = new StreamReader(@"c:\file2.txt") { File.AppendAllText(@"c:\file1.txt", sr.ReadToEnd()); } :)

              Luc Pattyn [My Articles] [Forum Guidelines]

              J Offline
              J Offline
              Jimmanuel
              wrote on last edited by
              #7

              File.AppendAllText("file1.txt", File.ReadAllText("file2.txt"));

              :)

              L 1 Reply Last reply
              0
              • J Jimmanuel

                File.AppendAllText("file1.txt", File.ReadAllText("file2.txt"));

                :)

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #8

                Nice; a real compact framework would offer File.Append("file1.txt", "file2.txt");

                Luc Pattyn [My Articles] [Forum Guidelines]

                J 1 Reply Last reply
                0
                • L Luc Pattyn

                  Nice; a real compact framework would offer File.Append("file1.txt", "file2.txt");

                  Luc Pattyn [My Articles] [Forum Guidelines]

                  J Offline
                  J Offline
                  Jimmanuel
                  wrote on last edited by
                  #9

                  Those lazy Microsoft bastards!!! Why haven't they thought of everything yet!?!?!

                  1 Reply Last reply
                  0
                  • C Colin Angus Mackay

                    Depends on the format of the file. Would you like to tell us more about these files?


                    Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." Ready to Give up - Your help will be much appreciated. My website

                    M Offline
                    M Offline
                    Martin 0
                    wrote on last edited by
                    #10

                    :confused: I'm allways surpriesed how there can be no reacton from the one who has a problem, after a response 9 minutes later. But maybe it's because the question had no "urgent" in the subject line! All the best, Martin

                    C 1 Reply Last reply
                    0
                    • M Martin 0

                      :confused: I'm allways surpriesed how there can be no reacton from the one who has a problem, after a response 9 minutes later. But maybe it's because the question had no "urgent" in the subject line! All the best, Martin

                      C Offline
                      C Offline
                      Colin Angus Mackay
                      wrote on last edited by
                      #11

                      Martin# wrote:

                      I'm allways surpriesed how there can be no reacton from the one who has a problem, after a response 9 minutes later.

                      It just goes to show you that too many people haven't got even the most basic of manners. Possibly they found the answer but just don't have the common courtesy to respond back to say they've got a solution. Or they really don't understand their own problem and are embarrased that they can't articulate themselves.

                      Martin# wrote:

                      But maybe it's because the question had no "urgent" in the subject line!

                      Just like this one[^] :rolleyes:


                      Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." Ready to Give up - Your help will be much appreciated. My website

                      1 Reply Last reply
                      0
                      • W WhiteGirl23

                        Hi, Can you tell me how to import a file in other file? thanks.

                        W Offline
                        W Offline
                        WhiteGirl23
                        wrote on last edited by
                        #12

                        thank you for helping me

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups