I was wondering if its possible to watch a folder and move the files each time there modifed so it would have to be running all the time. I am still very new to all this and any help would be apreciated before i start wasting time on somthing thats not even possible.

many thanks

will rose

.NET has a FileSystemWatcher control which monitors changes in a given directory and notifies if there are changes made. See MSDN documentation of FileSystemWatcher Class.

thanks for that it has def pointed me in the right direction i have got it to copy the file once it has been updated but it trys to do it twice here is my code

Dim FileGoto As String

FileGoto = "c:\watch\"

If e.ChangeType = IO.WatcherChangeTypes.Changed Then

System.IO.File.Copy(e.FullPath, FileGoto & e.Name)

End If

i think i am just missing somthing stupid :-P

Off the top of my head, with no testing done, I think it tries to do it more than once because there are different types of changes occuring in the file being watched... e.g Changes to its attributes, to its size, to the LastWriteTime and so on. When a file is written to, the size changes as well as the LastWriteTime and each of these changes causes the program to try to copy the file.

You're right that there actually happens two changes. File changes and the folder's attributes do change too. That causes a small problem.

willrose84 started a new thread "FileSystemWatcher Duplicting the same event" about that issue and I gave him/her a workaround solution.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.