copy data from one text file to other text file RRS feed

  • Question

  • I have a 1.txt file it contains some data ,another 2.txt file has some data, i want to copy  1.txt file data and paste it to 2.txt file data but data should place before 2.txt data

    ex: 1.txt file has 2 lines of data     adssdssdffdsfsfsfsdfdsf


     2.txt file has 3 line of data   xyz pqr sdad dadsd weqwe

                                             dada dadsda eqweq dadasd

                                              sdad eqew weqe  qeqweq w


    and i want like this                        adssdssdffdsfsfsfsdfdsf


                                                      xyz pqr sdad dadsd weqwe

                                                      dada dadsda eqweq dadasd

                                                       sdad eqew weqe  qeqweq w


    its urgent Help needed.Thanks

    Monday, August 1, 2011 9:41 AM


  • Hi

    Check with this


    StringBuilder fileContent = new StringBuilder(File.ReadAllText("D:\\Test.txt"));

     //perform string replace
    File.WriteAllText("D:\\Test3.txt", fileContent);



    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".
    Monday, August 1, 2011 9:48 AM