Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hii, everyone
i'm beginner how to display text i insert in textbox in notepad
Posted
Comments
Vani Kulkarni 12-Jul-12 2:54am    
This is not a well composed quesiton. Please elaborate using Improve question.

First you need to run Notepad, or ensure it is running already.
Then it's pretty simple. Have a look at this: http://stackoverflow.com/questions/523405/how-to-send-text-to-notepad-in-c-win32[^]
 
Share this answer
 
Use Process.Start to open a nodepad first and then copy text to notepad as mentioned here: similar thing[^]

Like:
C#
[DllImport("user32.dll", EntryPoint = "FindWindowEx")]
    public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
    [DllImport("User32.dll")]
    public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
    private void button1_Click(object sender, EventArgs e)
    {
        Process.Start("notepad.exe", "myfile");
        Process [] notepads=Process.GetProcessesByName("notepad");
        if(notepads.Length==0)return;
        if (notepads[0] != null)
        {
            IntPtr child= FindWindowEx(notepads[0].MainWindowHandle, new IntPtr(0), "Edit", null);
            SendMessage(child, 0x000C, 0, textBox1.Text);
        }
    }
 
Share this answer
 
Add name space system.IO

on btn_Click event
create object of StreamWriter as follows

C#
StreamWriter writer = new StreamWriter("C:\\Files\\abc.txt");
     writer.write(textbox1.text);
     writer.dispose()
 
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