Click here to Skip to main content
12,758,462 members (30,660 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
how to export data from textbox to notepad in C#?
Posted 15-Jan-13 13:54pm
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?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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);

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100