C#读取剪贴板内容并把内容记录在XML文件中
来源:互联网 发布:直播间刷屏软件 编辑:程序博客网 时间:2024/05/16 09:55
最近在做一个练习,就是用C# 2005写一个读取剪贴板的程序,并把读取的内容写进XML文件中!先和大家分享一下:
程序运界面如下:
xml文件如下:
程序代码如下:
因为是比较简单的代码,在这里就不做解释了!程序写得很烂,望高手们指点!
程序运界面如下:
xml文件如下:
程序代码如下:
因为是比较简单的代码,在这里就不做解释了!程序写得很烂,望高手们指点!
http://nicnet.cnblogs.com/archive/2006/02/28/339899.html
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
namespace WindowsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("Control.xml");
XmlNode root = xmlDoc.SelectSingleNode("monitor");
XmlElement xe1 = xmlDoc.CreateElement("state");
XmlElement xesub1 = xmlDoc.CreateElement("time");
xesub1.InnerText = DateTime.Now.ToString();
xe1.AppendChild(xesub1);
XmlElement xesub2 = xmlDoc.CreateElement("result");
IDataObject iData = Clipboard.GetDataObject();
if (iData.GetDataPresent(DataFormats.Text))
{
xesub2.InnerText = (string)iData.GetData(DataFormats.Text);
xe1.AppendChild(xesub2);
root.AppendChild(xe1);
xmlDoc.Save("Control.xml");
}
else
{
MessageBox.Show("剪贴板数据不是文本格式,请检查!", "错误");
this.Close();
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click_1(object sender, EventArgs e)
{
try
{
if (textBox1.Text != "" && int.Parse(textBox1.Text) != 0)
{
this.timer1.Interval = int.Parse(this.textBox1.Text);
}
}
catch
{
MessageBox.Show("请输入数字格式!");
}
finally
{
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
namespace WindowsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("Control.xml");
XmlNode root = xmlDoc.SelectSingleNode("monitor");
XmlElement xe1 = xmlDoc.CreateElement("state");
XmlElement xesub1 = xmlDoc.CreateElement("time");
xesub1.InnerText = DateTime.Now.ToString();
xe1.AppendChild(xesub1);
XmlElement xesub2 = xmlDoc.CreateElement("result");
IDataObject iData = Clipboard.GetDataObject();
if (iData.GetDataPresent(DataFormats.Text))
{
xesub2.InnerText = (string)iData.GetData(DataFormats.Text);
xe1.AppendChild(xesub2);
root.AppendChild(xe1);
xmlDoc.Save("Control.xml");
}
else
{
MessageBox.Show("剪贴板数据不是文本格式,请检查!", "错误");
this.Close();
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click_1(object sender, EventArgs e)
{
try
{
if (textBox1.Text != "" && int.Parse(textBox1.Text) != 0)
{
this.timer1.Interval = int.Parse(this.textBox1.Text);
}
}
catch
{
MessageBox.Show("请输入数字格式!");
}
finally
{
}
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<monitor>
<state>
<time>2006-02-27 17:00</time>
<result>001</result>
</state>
</monitor>
<monitor>
<state>
<time>2006-02-27 17:00</time>
<result>001</result>
</state>
</monitor>
- C#读取剪贴板内容并把内容记录在XML文件中
- c#读取xml文件的节点内容
- C#之读取XML文件内容
- C#读取XML文件的内容
- C#读取XML内容
- 读取xml文件内容
- 读取XML文件内容
- C#读取文件内容,在指定行插入内容
- 在Applet中读取文件内容
- 在Applet中读取文件内容
- 在Applet中读取服务器文件内容
- 将内容存放在剪贴板中
- delphi 剪贴板操作,读取剪贴板内容
- 如何读取XML文件内容!
- 如何读取XML文件内容
- 读取剪贴板内容js代码
- 读取剪贴板内容js代码
- python-pandas读取剪贴板内容
- 什么是屏幕坐标,什么是工作区坐标
- 昨晚,朋友小聚
- 如何在VC中利用系统函数创建一个新的线程
- 动态网页模板技术
- Simple Factory Pattern
- C#读取剪贴板内容并把内容记录在XML文件中
- Spring MVC意外更新PO的问题
- ASP.NET 小技巧:重写 ViewState 的存储目的地,以提高页面性能
- LCD设置的资料
- System.Web.SessionState
- Linux 系统的单用户模式、修复模式、跨控制台登录在系统修复中的运用
- 内核管理概述
- 手机也有感情的么??
- 用c#实现类似QQ的简单通讯程序