-2

im try to combine text file to filename. For example my path C:\Users\o.k\Desktop\Record\ record file has many .txt file. they names is

  • 20.07.2015-1.txt
  • 20.07.2015-2.txt
  • 20.07.2015-3LAST_try.txt
  • 20.07.2015-4.txt
  • 20.07.2015-5.txt
  • 20.07.2015-6LAST_a1.txt
  • 20.07.2015-7FIRST_a2.txt
  • 20.07.2015-8FIRST_a4.txt

this is first example write in 20.07.2015-1.txt file for example the other one in text file 20.07.2015-2.txt this is second example. i want to combine this 2 sentence like

  • this is first example
  • this is second example

create new text file then write in this 2 sentences.but this should for filename group.

20.07.2015-1.txt
20.07.2015-2.txt
20.07.2015-4.txt
20.07.2015-5.txt

this name format save together to main.txt

20.07.2015-3LAST_try.txt
20.07.2015-6LAST_a1.txt

this name format save together to LAST.txt

20.07.2015-7FIRST_a2.txt
20.07.2015-8FIRST_a4.txt

this name format save together to First.text

when click button it creates 3 type text file. Main,first and last. Main.txt file has contents of this files 20.07.2015-1.txt 20.07.2015-2.txt 20.07.2015-4.txt 20.07.2015-5.txt First.txt file has contents of this files 20.07.2015-7FIRST_a2.txt 20.07.2015-8FIRST_a4.txt etc.

ferfeit
  • 59
  • 2
  • 10
  • so you want both the txt files to combine and make 1 big text file? – Josh Stevens Jul 20 '15 at 11:52
  • no i want to 3 text file. main first and last. – ferfeit Jul 20 '15 at 11:54
  • dont understand what you need to happen – Josh Stevens Jul 20 '15 at 11:55
  • Neither do I. But to read a file you have System.IO.File.ReadAllLines and to write a file you gout System.IO.File.WriteAllLines. – 3Ducker Jul 20 '15 at 11:56
  • 1
    Please use the `edit` link under your original post to edit it, and include an actual question. – Kjartan Jul 20 '15 at 11:58
  • You now have asked 3 (undeleted) questions where you have been told on each of them that this is not an acceptable way to ask a question. You need to show what you have tried/researched and why that hasn't solved your problem. Read [ask] for more information. – Sayse Jul 20 '15 at 12:28

1 Answers1

0

Try this:

using (var output = File.Create("output"))
{
    foreach (var file in new[] { "file1", "file2" })
    {
        using (var input = File.OpenRead(file))
        {
            input.CopyTo(output);
        }
    }
}
DeshDeep Singh
  • 1,817
  • 2
  • 23
  • 43