943,769 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 462
  • VB.NET RSS
May 7th, 2009
0

Moving a file before its modifed

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
willrose84 is offline Offline
9 posts
since Apr 2009
May 8th, 2009
0

Re: Moving a file before its modifed

.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.
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008
May 8th, 2009
0

Re: Moving a file before its modifed

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
willrose84 is offline Offline
9 posts
since Apr 2009
May 13th, 2009
0

Re: Moving a file before its modifed

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
TriceD is offline Offline
21 posts
since Dec 2008
May 13th, 2009
0

Re: Moving a file before its modifed

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.
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Array
Next Thread in VB.NET Forum Timeline: Open form with new record





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC