怎么样动态创建一个实例,并且关闭它??? ( 积分: 100 )

  • 主题发起人 主题发起人 龙卷风241
  • 开始时间 开始时间

龙卷风241

Unregistered / Unconfirmed
GUEST, unregistred user!
//创建实例
private void createwatch(FileSystemWatcher watchclass,string path,string filter)
{
watchclass = new FileSystemWatcher(path,filter);
watchclass.Created += new FileSystemEventHandler(watchclass_Created);
watchclass.EnableRaisingEvents = true;
}
private void button2_Click(object sender, System.EventArgs e)
{
if(button2.Text=="开始监视")
{
FileSystemWatcher.
createwatch(new FileSystemWatcher(),filepath,filter);

button2.Text="停止监视";
}
else
{
???怎么写这个函数(StopWatch();)

button2.Text="开始监视";
}
 
//创建实例
private void createwatch(FileSystemWatcher watchclass,string path,string filter)
{
watchclass = new FileSystemWatcher(path,filter);
watchclass.Created += new FileSystemEventHandler(watchclass_Created);
watchclass.EnableRaisingEvents = true;
}
private void button2_Click(object sender, System.EventArgs e)
{
if(button2.Text=="开始监视")
{
FileSystemWatcher.
createwatch(new FileSystemWatcher(),filepath,filter);

button2.Text="停止监视";
}
else
{
???怎么写这个函数(StopWatch();)

button2.Text="开始监视";
}
 
在线等呀
 
用free釋放一個實例
 
后退
顶部