|
using System;
using System.IO;
namespace FileRenamer2
{
public class FileChangeEventArgs
{
public string FolderPath = "";
public string ChangeType = "";
}
public delegate void FileChangedEventHandler(object sender, FileChangeEventArgs e);
class FileChangeWatcher
{
FileSystemWatcher Watcher = new FileSystemWatcher();
public event FileChangedEventHandler eFileChanged;
private string m_FolderPath = "";
public string FolderPath
{ get { return m_FolderPath; } set { m_FolderPath = value; Watcher.Path = value; } }
public FileChangeWatcher()
{
Watcher.Filter = "*.*";
Watcher.IncludeSubdirectories = true;
Watcher.NotifyFilter = NotifyFilters.DirectoryName | NotifyFilters.FileName;
Watcher.Created += new FileSystemEventHandler(Watcher_Created);
Watcher.Deleted += new FileSystemEventHandler(Watcher_Deleted);
Watcher.Renamed += new RenamedEventHandler(Watcher_Renamed);
}
void Watcher_Renamed(object sender, RenamedEventArgs e)
{
if (eFileChanged != null)
{
FileChangeEventArgs args = new FileChangeEventArgs();
args.FolderPath = m_FolderPath;
args.ChangeType = "Rename";
eFileChanged(this, args);
}
}
void Watcher_Deleted(object sender, FileSystemEventArgs e)
{
if (eFileChanged != null)
{
FileChangeEventArgs args = new FileChangeEventArgs();
args.FolderPath = m_FolderPath;
args.ChangeType = "Deleted";
eFileChanged(this, args);
}
}
void Watcher_Created(object sender, FileSystemEventArgs e)
{
if (eFileChanged != null)
{
FileChangeEventArgs args = new FileChangeEventArgs();
args.FolderPath = m_FolderPath;
args.ChangeType = "Created";
eFileChanged(this, args);
}
}
public void Start()
{
Watcher.EnableRaisingEvents = true;
}
public void Stop()
{
Watcher.EnableRaisingEvents = false;
}
} // end class
} // end namespace
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
To keep it simple, I'll just list my computer/software experience.
1970 learned BASIC on an IBM 360 timeshare terminal while working for MCI when we consisted of about a dozen people.
1978 bought an Apple II Plus with a floppy drive [140kbytes!! wow! ha ha ha].
1978-1985 sharpened my programming skills in BASIC, Forth, assembly language, and Pascal on the Apple II which I upgraded along the way. I was a member of the A.P.P.L.E. and submitted several programs and articles to various bulletin boards. Received a couple of awards.
1985 bought my first PC.
1985-2000 Eventually tried Windows 286 and tossed it, then finally bought Windows 386 and kept it. Studied and passed the MCSE certification. Added C and C++ to my repertoire and started building programs for Windows for Workgroups 3.11. Got a couple of awards for utilites I wrote.
2000 I retired from my 'day job' in electronics and went to work full time as a programmer/analyst and network engineer.
2000-2005 worked on web and client server software. The applications included web and desktop based learning software including testing, progress reporting, etc.
Worked with another guy in creating a web based parts catalog on an SQL Server database from the ashes of a web fiasco they bought based on MS Access. I then built a massive MS Word VBA based catalog generator for them that took the SQL database and generated their 1,000 page catalog.
2005-2007 worked as a contract programmer. Supported magazine fulfillment and billing via web apps in ASP and ASP .Net. Upgraded my skillset to the .Net universe.
2007-2010 worked for a large manufacturing corporation's shop floor software support. Analyzed and mapped out the two dozen applications and two dozen flat files plus a half dozen SQL Server db's that supported and controlled the entire manufacturing process. Created a math intensive app to convert customer orders into machine control data.
2010 - retired... sort of... *grin*