Click here to Skip to main content
15,948,339 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to export data from textbox to notepad in C#?
Jibesh 15-Jan-13 19:15pm    
what do you really mean by export? copy paste? write to file and open in note pad? there are many variants for export. which one you are referring to?

Share this answer
Code Credit Here:[^]

Code from their answer:


using System.Runtime.InteropServices;


public static class NotepadHelper
        [DllImport("user32.dll", EntryPoint = "SetWindowText")]
        private static extern int SetWindowText(IntPtr hWnd, string text);

        [DllImport("user32.dll", EntryPoint = "FindWindowEx")]
        private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

        [DllImport("User32.dll", EntryPoint = "SendMessage")]
        private static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);

        public static void ShowMessage(string message = null, string title = null)
            Process notepad = Process.Start(new ProcessStartInfo("notepad.exe"));

            if (!string.IsNullOrEmpty(title))
                SetWindowText(notepad.MainWindowHandle, title);

            if (notepad != null && !string.IsNullOrEmpty(message))
                IntPtr child = FindWindowEx(notepad.MainWindowHandle, new IntPtr(0), "Edit", null);
                SendMessage(child, 0x000C, 0, message);


NotepadHelper.ShowMessage(textbox1.Text, textbox2.Text);
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