Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Determine when a file is ready

6 views
Skip to first unread message

Nicholas Paldino [.NET/C# MVP]

unread,
Jan 29, 2008, 5:01:48 PM1/29/08
to
A similar question was posted a few days ago, with the following
replies:

http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/8fa022dea366f46d/496e3132135ea3c6?lnk=st&q=filesystemwatcher+nicholas+paldino#496e3132135ea3c6


--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"sbparsons" <sbpa...@discussions.microsoft.com> wrote in message
news:7128A17F-9BFA-427B...@microsoft.com...
>I need to write an app that picks up images from a folder and does some
>work
> on them (resize, compress etc). The folder in which the images reside has
> a
> FileSystemWatcher triggering events when files are dropped in.
>
> I need to be able to determine when the file is ready to be accessed by my
> app, as some of the files may be large and the copy procedure may take
> some
> time (in the order of seconds). I have the LastWrite filter set on my FSW
> but
> that raises the changed event - which is also raised at other (seemingly
> random) times - and there is no info in the event raised that it is the
> LastWrite stage of the action.
>
> Is there any exact way of determining when the file is available? This is
> through a windows service so can't use the Win32 SHFileOperation api
> call...
> (and a 'try - catch' solution isn't ideal)


sbparsons

unread,
Jan 29, 2008, 5:04:01 PM1/29/08
to
Thanks Nicholas - sorry, I should have searched on a few more keywords.

Scott Roberts

unread,
Jan 29, 2008, 5:21:44 PM1/29/08
to
A batch file interface that I worked on several years ago used file
extensions instead of the file "marker" idea. The client would write files
into the directory with a "*.wrk" extension then rename them to the
appropriate extension once the file has been completely written. The server
would ignore "*.wrk" files and was free to process all other files. I
believe that the "rename" function does not actually open the file and so
sharing violations are not possible.

As Nicholas said, if you can't control the client process you're kinda stuck
with try...catch.


"Nicholas Paldino [.NET/C# MVP]" <m...@spam.guard.caspershouse.com> wrote in
message news:e7UEhHsY...@TK2MSFTNGP02.phx.gbl...

0 new messages