471,319 Members | 2,625 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

FileSystemWatcher Copy Large File

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
Jan 8 '06 #1
3 3501
Hi,

"Kenneth H. Brannigan" <Kenneth H. Br*******@discussions.microsoft.com>
wrote in message news:8C**********************************@microsof t.com...
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.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 9 '06 #2
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

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

"Kenneth H. Brannigan" <Kenneth H. Br*******@discussions.microsoft.com>
wrote in message news:8C**********************************@microsof t.com...
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.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Jan 9 '06 #3
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.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Kenneth H. Brannigan" <Ke***************@discussions.microsoft.com> wrote
in message news:A2**********************************@microsof t.com...
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

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

"Kenneth H. Brannigan" <Kenneth H. Br*******@discussions.microsoft.com>
wrote in message
news:8C**********************************@microsof t.com...
> 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.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Jan 10 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Josh Usovsky | last post: by
2 posts views Thread by Steel City Phantom | last post: by
2 posts views Thread by John Lee | last post: by
1 post views Thread by Phil396 | last post: by
1 post views Thread by Megan | last post: by
4 posts views Thread by somequestion | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.