Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
in c sharp window application how can read text from one text box and then how can copy those to another text box using system.io.......??
Posted
Comments
Marco Bertschi 11-Jan-13 8:09am    
Do you want to copy the text from text box to text box or from one file to another file?
prajwal rao 11-Jan-13 8:12am    
i need both of them....

C#
// copying from one to another
textbox2.Text = textbox1.Text;


You can write your text to a file using the TextWriter Class[^].
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 15-Jan-13 2:06am    
My 5, but this is one of multiple re-posts, and abuse.
—SA
Copying from one to another text box:
Use the solution 1 from RMC[^]:
C#
// copying from one to another text box
textbox2.Text = textbox1.Text;


For copying files you can use this:
C#
using System;
using System.IO;

namespace FileSystemIO
{
    class Program
    {
        static void Main(string[] args)
        {
            string sourceFile = "C:\Temp\test.txt";//Original file path
            string destinationFile = "C:\Temp\test_copied.txt";//path of the copied file

            try
            {
                File.Copy(sourceFile, destinationFile); //Copy the file

                Console.WriteLine("File copied successfully");//Write succesful message if no exception raised
            }
            catch(Exception ex)
            {
                Console.WriteLine("Copying file failed: " + ex.Message); //Write error message if no exception raised.
            }

            Console.ReadKey();//Wait for user pressing key before ending program
        }
    }
}


More info about the System.IO.File.Copy() method[^] can you find on the MSDN page.

cheers,
Marco Alessandro Bertschi
 
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