创建硬盘读写事件
我正在尝试编写一些在硬盘读取数据或写入数据时触发事件的东西。我知道这涉及使用 System.Diagnostics.PerformanceCounter 但我对此了解不够,无法自己完成此操作。有人能指出我正确的方向吗?另外,我希望触发事件以返回正在读取或写入的驱动器。任何帮助将不胜感激。顺便说一句,这是 C#。
I am trying to write something that will fire an event anytime the hard disk reads data or writes data. I know this involves using System.Diagnostics.PerformanceCounter but I don't know this well enough to be able to do this on my own. Can someone point me in the right direction? Also, I'd like the event that fires to return which drive is being read or written to. Any help would be appreciated. This is C#, by the way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下不会创建事件,但您可以将其与计时器一起使用以在托盘中显示信息(根据注释):
_Total
适用于所有磁盘...获取可用磁盘的特定实例名称使用:然后,您可以为您感兴趣的每个实例创建一对
diskRead
/diskWrite
...有关如何将其与计时器结合使用的示例,请参阅< a href="http://miteshsureja.blogspot.de/2012/01/performance-counters-in-net.html" rel="noreferrer">这个。The following does not create events but you could use it together with a timer to display information in the tray (as per comments):
_Total
is for ALL disks... to get the specific instancenames of available disks use:you can then create a pair of
diskRead
/diskWrite
for every instance you are interested in... for sample on how to use this in combination with a timer see this.