开发者

vb.net how to check for changes in folder upon application start?

while the application is running i'm using FileSystemWatcher to monitor the folder. But what if there are changes to the folder when the application is not running, how can I check for these changes when the application starts.

(similar to how windows media player, for example, monitors your music folder. Even when you add songs to that folder when it is not running, it does discover them whe开发者_Python百科n it runs next time)

Thanks


You could store a list of what has already been found in a file and then compare it with the current state at startup.
Otherwise you could create a service that starts at system startup and always watches the folder and when your app starts up it polls the service for any changes since it last polled.


You can use the LastWriteTime which is in the System.IO.Directory or in the System.IO.DirectoryInfo.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜