Click here to Skip to main content
16,006,006 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to copy text from two .txt file and then want to paste in the third .txt file.
Posted
Comments
BillWoodruff 16-Oct-15 0:26am    
This is relatively simple to do provided you have permission to access both files, and permission to create a new file in the directory you intend to create it in.

So, what have you tried ? Show some code. We are not going to do your homework, or your coding, for you.

Hi, try this code, and refer System.IO namespace in your project.
C#
string FirstFileContents = File.ReadAllText("your first file path here");
string SecondFileContents = File.ReadAllText("your second file path here");
StringBuilder ThirdFileContents = new StringBuilder();
ThirdFileContents.Append(ThirdFileContents.ToString());

File.WriteAllText("your third file path here", ThirdFileContents);
 
Share this answer
 
Comments
BillWoodruff 16-Oct-15 1:45am    
Are you going to everyone's homework ?
You're lacking the basic idea here.
First you need to read the text from both the files, store it in some object/collection (whichever you prefer) and then write it to some different file.
(Make sure that you have appropriate permissions to access the file.)

Look at this & you're good to go then,
Read from a File[^]
Write to a File[^]

-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900