请,如何显示我在记事本中的文本框中插入的文本 [英] please , how to display text i insert in textbox in notepad

查看:96
本文介绍了请,如何显示我在记事本中的文本框中插入的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我
我是初学者,如何显示文本,请在记事本中的文本框中插入文本

hii, everyone
i''m beginner how to display text i insert in textbox in notepad

推荐答案

首先,您需要运行记事本,或者确保它已经在运行. 然后,这非常简单.看看这个: http://stackoverflow.com/Questions/523405/how-to-send-text-to-notepad-in-c-win32 [
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[^]


使用Process.Start首先打开节点板,然后然后按照以下说明将文本复制到记事本:类似的东西 [ ^ ]

像:
Use Process.Start to open a nodepad first and then copy text to notepad as mentioned here: similar thing[^]

Like:
[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);
        }
    }


添加名称空间系统.IO

关于btn_Click事件
创建StreamWriter的对象,如下所示

Add name space system.IO

on btn_Click event
create object of StreamWriter as follows

StreamWriter writer = new StreamWriter("C:\\Files\\abc.txt");
     writer.write(textbox1.text);
     writer.dispose()


这篇关于请,如何显示我在记事本中的文本框中插入的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆