如何使用Windows Service监视文件大小? [英] How to monitor file size using windows service?

查看:106
本文介绍了如何使用Windows Service监视文件大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建一个Windows服务,以便它监视目录中的文件大小并在大小达到特定限制的任何地方弹出一条消息.我是C#的新手,所以我不确定如何开始.我在网上四处探索,但都没有显示如何监视文件大小.

I want to construct a windows service whereby it monitor the file size in a directory and pop up a message wherever the size reaches a certain limit. I''m quite new with c# so I''m not sure how to start. I explore little bit here and there on the net but none of it shows on how to monitor file size. Any kind of help would really be appreciated.

推荐答案

您需要使用类System.IO.FileSystemWatcher,请参见:
http://msdn.microsoft.com/en-us/library/system.io. filesystemwatcher.aspx [ ^ ].



这种方法允许采用推送技术方法,请参阅:
http://en.wikipedia.org/wiki/Push_technology [
You need to use the class System.IO.FileSystemWatcher, please see:
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx[^].



This approach allows for push technology approach, please see:
http://en.wikipedia.org/wiki/Push_technology[^].

The pull technology is always bad, ineffective, it would imply periodic polling. Nothing happens to the file system, but you would still poll in vain. Something happens, but you are not responsive, because you use some polling period…


—SA


真的吗?您找不到如何获取文件大小? http://msdn.microsoft.com/en-us/library/system. io.fileinfo.length.aspx [ ^ ]
Really? You could not find how to get the file size? http://msdn.microsoft.com/en-us/library/system.io.fileinfo.length.aspx[^]


这篇关于如何使用Windows Service监视文件大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆