FileSystemWatcher Copy Large File

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I have a FileSystemWatcher looking at a particular directory. When I copy a
large file (750 MB) to this directory I receive multiple Change events. I am
fine with this but when I call File.GetLastWriteTime in the Change event it
returns the current date and time not the date and time windows explorer
shows as Last Write Time. If the file is small everything works fine. Is
there a way to fix this issue?

Thanks,
Ken
 
Hi,

Kenneth H. Brannigan said:
Hello,
I have a FileSystemWatcher looking at a particular directory. When I copy
a
large file (750 MB) to this directory I receive multiple Change events. I
am
fine with this but when I call File.GetLastWriteTime in the Change event
it
returns the current date and time not the date and time windows explorer
shows as Last Write Time. If the file is small everything works fine. Is
there a way to fix this issue?

The FilesystemWatcher is far from be an exact science. Probably you get
that time cause the file still is being changed (or open to write).
Unfortunately there is no CloseFile event, so you dont know when the file
was closed.

If the file is small probably what is happening is that the file is closed
already by the time you handle the LastWrite event.
 
Hello,
Any suggestions on a work around? Is there something beside the
fileSystemWatcher that should be utilized. Anyway to determine when the file
is finished with the copy process?
Thanks,
Ken
 
Hi,

Well if you program itself copy the file you can rise an event when the file
is copied completely.

Other than that, I do not think you have a way.

A dirty solution could be trying to open the file for write, as it's open by
another process you should get an exception, you put this in a timer and you
are done.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top