一个简单的编程,重酬!

社区服务
高级搜索
猴岛论坛电脑百科一个简单的编程,重酬!
发帖 回复
正序阅读 最近浏览的帖子最近浏览的版块
6个回复

[技术小组]一个简单的编程,重酬!

楼层直达
lzk2231204

ZxID:18187770

等级: 新兵
举报 只看楼主 使用道具 楼主   发表于: 2012-05-23 0
在无安全插件的情况下,当插入U盘后,自动复制U盘所有内容到D盘,重酬!联系QQ:247061637
luo280231500

ZxID:4999137

等级: 中士
举报 只看该作者 6楼  发表于: 2012-06-29 0
防晒霜
防晒霜
小红蜻蜓

ZxID:17929108

等级: 中校
举报 只看该作者 5楼  发表于: 2012-05-24 0
三楼牛逼。。。

际遇之神

奖励

被富婆包养,轻易就获得钱财无数,获得6DB

esprit www.espritfz.com利郎男装www.lilnz.com
www.fuannajf.net 才子男装www.caizinz.com jeep男装www.jeepnz.info罗蒙男装www.luomeng.info 卡宾男装www.kabinmall.com
baioof

ZxID:17536459

等级: 中校
举报 只看该作者 4楼  发表于: 2012-05-23 0
厉害,,,
 Hazel丶瘾

ZxID:16550531

等级: 中将
举报 只看该作者 地板   发表于: 2012-05-23 0
好长
luowei631022

ZxID:11063601

等级: 大尉
www.luoweiqq.cn-www.huaxieyu.com
举报 只看该作者 板凳   发表于: 2012-05-23 0
看看这个,如果懂这些的话应该明白这什么意思

C# codeusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Configuration;using MTClient.Utility;using System.Threading;namespace UDiskMonitor
{publicpartialclass MainForm : Form
{bool isCopy=false;bool isCopyEnd=false;string targetdir=null;publicconstint WM_DEVICECHANGE=0x219;publicconstint DBT_DEVICEARRIVAL=0x8000;publicconstint DBT_CONFIGCHANGECANCELED=0x0019;publicconstint DBT_CONFIGCHANGED=0x0018;publicconstint DBT_CUSTOMEVENT=0x8006;publicconstint DBT_DEVICEQUERYREMOVE=0x8001;publicconstint DBT_DEVICEQUERYREMOVEFAILED=0x8002;publicconstint DBT_DEVICEREMOVECOMPLETE=0x8004;publicconstint DBT_DEVICEREMOVEPENDING=0x8003;publicconstint DBT_DEVICETYPESPECIFIC=0x8005;publicconstint DBT_DEVNODES_CHANGED=0x0007;publicconstint DBT_QUERYCHANGECONFIG=0x0017;publicconstint DBT_USERDEFINED=0xFFFF;public MainForm()
{
InitializeComponent();
}privatevoid MainForm_Load(object sender, EventArgs e)
{

}privatevoid CopyFile(string path)
{
isCopyEnd=true;if (isCopy)
{
DirectoryHelper dir=new DirectoryHelper();
targetdir= DateTime.Now.ToString();
targetdir= targetdir.Replace(':','-');
targetdir= ConfigReader.GetValue("targetdir")+ targetdir;//ConfigurationManager.AppSettings["targetdir"].ToString() + targetdir;if (!Directory.Exists(targetdir))
{
Directory.CreateDirectory(targetdir);
}else
{
listBox1.Items.Add(DateTime.Now.ToString()+"--> 文件夹已经存在,请确认!");return;
}

dir.CopyDirectoryAndFiles(targetdir,new DirectoryInfo(path));
listBox1.Items.Add(DateTime.Now.ToString()+"--> 已完成数据拷贝!");
listBox1.Items.Add(DateTime.Now.ToString()+"--> 正在检查文件合法性!");
listBox1.Items.Add(DateTime.Now.ToString()+"--> 文件合法!");
listBox1.Items.Add(DateTime.Now.ToString()+"--> 数据正在入库!");
}
}protectedoverridevoid WndProc(ref Message m)
{try
{if (m.Msg== WM_DEVICECHANGE)
{switch (m.WParam.ToInt32())
{case WM_DEVICECHANGE:break;case DBT_DEVICEARRIVAL://U盘插入 DriveInfo[] s= DriveInfo.GetDrives();foreach (DriveInfo drivein s)
{if (drive.DriveType== DriveType.Removable)
{
listBox1.Items.Add(DateTime.Now.ToString()+"--> U盘已插入,盘符为:"+ drive.Name.ToString());
Thread.Sleep(1000);if (!isCopyEnd)
{
isCopy=true;
CopyFile(drive.Name+ ConfigurationManager.AppSettings["sourcedir"].ToString());
}break;
}
}break;case DBT_CONFIGCHANGECANCELED:break;case DBT_CONFIGCHANGED:break;case DBT_CUSTOMEVENT:break;case DBT_DEVICEQUERYREMOVE:break;case DBT_DEVICEQUERYREMOVEFAILED:break;case DBT_DEVICEREMOVECOMPLETE://U盘卸载 listBox1.Items.Add(DateTime.Now.ToString()+"--> U盘已卸载!");
isCopy=false;
isCopyEnd=false;break;case DBT_DEVICEREMOVEPENDING:break;case DBT_DEVICETYPESPECIFIC:break;case DBT_DEVNODES_CHANGED:break;case DBT_QUERYCHANGECONFIG:break;case DBT_USERDEFINED:break;default:break;
}
}
}catch (Exception ex)
{
MessageBox.Show(ex.Message);
}base.WndProc(ref m);
}privatevoid btnConfig_Click(object sender, EventArgs e)
{
Config config=new Config();
config.ShowDialog();
}
}
}
[ 此帖被luowei631022在2012-05-23 16:03重新编辑 ]

际遇之神

奖励

为练葵花宝典,忍辱负重,最终获得5DB

武汉seoseo技术www.aweiblog.com
孤影随风

ZxID:15699962

等级: 贵宾
举报 只看该作者 沙发   发表于: 2012-05-23 0
请不要重复发帖
« 返回列表
发帖 回复