Here are the examples of the csharp api InTheHand.IO.FileSystemWatcher.OnChanged(System.IO.FileSystemEventArgs) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
19
Source : FileSystemWatcher.cs
with MIT License
from inthehand
with MIT License
from inthehand
protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message msg)
{
if (msg.Msg == NativeMethods.WM_FILECHANGEINFO)
{
if (msg.LParam == IntPtr.Zero)
return;
NativeMethods.FILECHANGENOTIFY fchnot = (NativeMethods.FILECHANGENOTIFY)Marshal.PtrToStructure(msg.LParam, typeof(NativeMethods.FILECHANGENOTIFY));
string fullPath = fchnot.dwItem1;
string newfullPath = fchnot.dwItem2;
string fileName = System.IO.Path.GetFileName(fullPath);
string dirName = System.IO.Path.GetDirectoryName(fullPath);
string newfileName = string.Empty;
if (fchnot.dwItem2 != null)
{
newfileName = System.IO.Path.GetFileName(fchnot.dwItem2);
}
if (CheckFilter(fileName))
{
FileSystemEventArgs args;
RenamedEventArgs renArgs;
switch (fchnot.wEventId)
{
case NativeMethods.SHCNE.CREATE:
if ((watcher.notifyFilters & NotifyFilters.FileName) == NotifyFilters.FileName)
{
args = new FileSystemEventArgs(WatcherChangeTypes.Created, dirName, fileName);
watcher.OnCreated(args);
}
break;
case NativeMethods.SHCNE.MKDIR:
if ((watcher.notifyFilters & NotifyFilters.DirectoryName) == NotifyFilters.DirectoryName)
{
args = new FileSystemEventArgs(WatcherChangeTypes.Created, dirName, fileName);
watcher.OnCreated(args);
}
break;
case NativeMethods.SHCNE.UPDATEDIR:
if ((watcher.notifyFilters & NotifyFilters.DirectoryName) == NotifyFilters.DirectoryName)
{
args = new FileSystemEventArgs(WatcherChangeTypes.Changed, dirName, fileName);
watcher.OnChanged(args);
}
break;
case NativeMethods.SHCNE.RMDIR:
if ((watcher.notifyFilters & NotifyFilters.DirectoryName) == NotifyFilters.DirectoryName)
{
args = new FileSystemEventArgs(WatcherChangeTypes.Deleted, dirName, fileName);
watcher.OnDeleted(args);
}
break;
case NativeMethods.SHCNE.DELETE:
if ((watcher.notifyFilters & NotifyFilters.FileName) == NotifyFilters.FileName)
{
args = new FileSystemEventArgs(WatcherChangeTypes.Deleted, dirName, fileName);
watcher.OnDeleted(args);
}
break;
case NativeMethods.SHCNE.UPDATEITEM:
if ((watcher.notifyFilters & NotifyFilters.FileName) == NotifyFilters.FileName)
{
args = new FileSystemEventArgs(WatcherChangeTypes.Changed, dirName, fileName);
watcher.OnChanged(args);
}
break;
case NativeMethods.SHCNE.RENAMEFOLDER:
if ((watcher.notifyFilters & NotifyFilters.DirectoryName) == NotifyFilters.DirectoryName)
{
renArgs = new RenamedEventArgs(WatcherChangeTypes.Renamed, dirName, newfileName, fileName);
watcher.OnRenamed(renArgs);
}
break;
case NativeMethods.SHCNE.RENAMEITEM:
if ((watcher.notifyFilters & NotifyFilters.FileName) == NotifyFilters.FileName)
{
renArgs = new RenamedEventArgs(WatcherChangeTypes.Renamed, dirName, newfileName, fileName);
watcher.OnRenamed(renArgs);
}
break;
case NativeMethods.SHCNE.ATTRIBUTES:
if ((watcher.notifyFilters & NotifyFilters.Attributes) == NotifyFilters.Attributes)
{
args = new FileSystemEventArgs(WatcherChangeTypes.Changed, dirName, fileName);
watcher.OnChanged(args);
}
break;
}
}
NativeMethods.SHChangeNotifyFree(msg.LParam);
}
msg.Result = IntPtr.Zero;
base.WndProc(ref msg);
}