我爱Aspx >> Asp.Net >> Create and Control Windows Services--Add File-Monitoring Functionality[等级:高级]public class PlatformInvokeKernel32
{
[sysimport(dll="kernel32", charset=System.Runtime.InteropServices.CharSet.Auto)]
public static extern int
GetDriveType (string lpRootPathName);
}
This code simply forwards all calls using PlatformInvokeKernel32.GetDriveType() to the associated function in kernel32.dll. To get the drive type for each drive in the array, check the value returned from the call to the enumerated type win from the Microsoft.Win32.Interop namespace:
string[] drives = Environment.GetLogicalDrives();
// create filesystem watchers for
// local fixed drives
foreach (string curDrive in drives )
{
if (
PlatformInvokeKernel32.GetDriveType
(curDrive) == win.DRIVE_FIXED)
{
// create a FileSystemWatcher
}
}
Now that you@#ve created the FileSystemWatcher objects, you must implement the event handlers for the four file notification events: creating, changing, deleting, and renaming files. You@#ll create performance counters that convey information to the user visually—one for each event. For more information on file notification event handlers and creating performance counters, download the code that accompanies this article. To create a performance counter, use the PerformanceCounter class specified in the System.Diagnostics namespace. When you call the file change event handler, it simply increments the proper performance counter by 1:
Ҷƪл˵?
Create and Control Windows Ser..[05-28]
Create and Control Windows Ser..[05-28]
Consuming a Webservice Part 2 ..[05-28]
Creating a Webservice Part 1 o..[05-28]
一个用webservice behavior实现的..[05-28]
加强 WEB SERVICE 的安全性[05-28]
WebService Behavior的一个中文B..[05-28]
Web服务到底是什么(转)[05-28]
WEB服务有待实践的检验[05-28]
一个webseveice的例子[05-28]