using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FileWatcher
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnStart_Click(object sender, EventArgs e)
{
fileSystemWatcher.Path = txtPath.Text.Trim();
fileSystemWatcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.DirectoryName;
fileSystemWatcher.IncludeSubdirectories = true;
fileSystemWatcher.EnableRaisingEvents = true;
}
private void fileSystemWatcher_Changed(object sender, System.IO.FileSystemEventArgs e)
{
lstMessages.Items.Add("Changed:" + e.FullPath);
}
private void fileSystemWatcher_Created(object sender, System.IO.FileSystemEventArgs e)
{
lstMessages.Items.Add("Created:" + e.FullPath);
}
private void fileSystemWatcher_Deleted(object sender, System.IO.FileSystemEventArgs e)
{
lstMessages.Items.Add("Deleted:" + e.FullPath);
}
}
}
|