Moving a file before its modifed

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2009
Posts: 6
Reputation: willrose84 is an unknown quantity at this point 
Solved Threads: 0
willrose84 willrose84 is offline Offline
Newbie Poster

Moving a file before its modifed

 
0
  #1
May 7th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: Moving a file before its modifed

 
0
  #2
May 8th, 2009
.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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 6
Reputation: willrose84 is an unknown quantity at this point 
Solved Threads: 0
willrose84 willrose84 is offline Offline
Newbie Poster

Re: Moving a file before its modifed

 
0
  #3
May 8th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 18
Reputation: TriceD is an unknown quantity at this point 
Solved Threads: 0
TriceD TriceD is offline Offline
Newbie Poster

Re: Moving a file before its modifed

 
0
  #4
May 13th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: Moving a file before its modifed

 
0
  #5
May 13th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC