mazrabul
mazrabul

Reputation: 295

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 when it runs next time)

Thanks

Upvotes: 0

Views: 467

Answers (2)

Iraklis
Iraklis

Reputation: 810

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

Upvotes: 0

Hans Olsson
Hans Olsson

Reputation: 55059

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.

Upvotes: 2

Related Questions