Click here to Skip to main content
12,247,267 members (57,280 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
Comments
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
 
good
Please Sign up or sign in to vote.

Solution 1

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

Solution 2

Code Credit Here: http://stackoverflow.com/questions/7613576/how-to-open-text-in-notepad-from-net#answer-14295249[^]

Code from their answer:

usings

using System.Runtime.InteropServices;

code

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"));
            notepad.WaitForInputIdle();
 
            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);
            }
        }
    }


usage

NotepadHelper.ShowMessage(textbox1.Text, textbox2.Text);
  Permalink  

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.160426.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2016
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