monitor a folder's files

VBnetster

Active member
Joined
Feb 15, 2008
Messages
32
Programming Experience
Beginner
Hi all

Is there some way i can monitor all files in a folder? "(only text files) and when any of the files in this folder is deleted/moved the program will show a message box saying it has been deleted or moved.

by moved i mean dragged to another location or copy/pasted.


I know u can monitor a folder not sure about the files in it and such functions as above..

thanks guys/girls
 
Nothing ever works.. most common error is:

lstFiles.Items.Add(Now.ToString() & " Processed " & file_name)
Cross-thread operation not valid: Control 'lstFiles' accessed from a thread other than the thread it was created on.

On such lines as that. Also i tried tons of example codes from planet source code and nothing works i get the same error from any of them that uses a listbox. i tried the one from microsoft (link u gave me) and that doesnt work either. I'm using visual basic 2008
 
FileSystemWatcher is as easy as watching ice melt. It does not raise events on different thread. So I have no idea what your post is about, did you post in wrong thread?

I'll elaborate a second; add one to form, set Path to "c:\temp", add this code to Renamed event:
VB.NET:
Me.Label1.Text = String.Format("{0} changed to {1}", e.OldName, e.Name)
Run app and change a filename in that path, then watch label.
 
i feel dumb lol


thanks!

can this only monitor a directory + sub dirs or can it monitor the entire hard drive somehow? I was thinking that some kind of hooking would be required for this job?
 
Back
Top