R
rwbean86
I found that I'm able to determine whether a file is in the process of
being moved or copied to a landing directory that I monitor. I figure
this out by attempting to open the file for reading. If I try the open
and get FileIOException I decide that the file is in transit. If there
is no exception then the I decide move/copy is complete.
My question is: is there a better way? I ask this because handling
FileIOException seems a little too broad when what I really want is to
figure out if the file is coming. I've tried checking the file size,
last access, last write. This doesn't seem to work. The exception
message tells me that the file is being used by another process. That
narrows things down a bit, but can I be sure that message will not
change. Can I be sure that another process has not locked the file and
accidently left it in that state. I need to move on to other files if
that's the case.
Thanks for your thoughts.
being moved or copied to a landing directory that I monitor. I figure
this out by attempting to open the file for reading. If I try the open
and get FileIOException I decide that the file is in transit. If there
is no exception then the I decide move/copy is complete.
My question is: is there a better way? I ask this because handling
FileIOException seems a little too broad when what I really want is to
figure out if the file is coming. I've tried checking the file size,
last access, last write. This doesn't seem to work. The exception
message tells me that the file is being used by another process. That
narrows things down a bit, but can I be sure that message will not
change. Can I be sure that another process has not locked the file and
accidently left it in that state. I need to move on to other files if
that's the case.
Thanks for your thoughts.