Re: FileSystemWatcher and Getting Access to a file
From: gregory_may (None)
Date: 08/02/04
- Next message: mikeb: "Re: Reg Compilers"
- Previous message: bruce barker: "Re: event handling with user controls"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 2 Aug 2004 09:18:37 -0700
I will past the text from the link -
http://www.dotnet247.com/247reference/msgs/29/146407.aspx:
I am having the same problem. Is there a better solution????:
----
I am trying to use the System.IO.FileSystemWatcher class
to watch for new files in a directory. The problem I'm
having is that it seems the 'oncreate' event fires before
the new file is completely written. Therefore when I try
to do anything with the file (such as copy the file to
another directory) I get an error message along the lines
of "The process cannot access the file because it is being
used by another process." The only solution I've found is
to catch this exception and just keep trying to process
the file until the exception goes away. This solution
isn't working well and it seems there has to be a better
way to solve this problem. Has anyone found a better
solution to this?
Thanks in advance for any advice.
Reply to this message...
prowler
I faced the exact same issue and made a workaround by
trying to continually open the file with FileShare.None,
and ignoring a particular exception. Once this succeeds I
proceed further. The files I was dealing with could take
several minutes to come in. Fortunately the app is not
extremely performance intensive and I can do a
Thread.Sleep for a minute and check back.
I was wishing there was amore elegant way to deal wth
this. Would like to find out.
-prowler
"Lebrun Thomas" <lebrun.thomas@wanadoo.fr> wrote in message
news:eEejMTldEHA.3420@TK2MSFTNGP12.phx.gbl...
> > Does anyone have a more
> > elegant solution to this problem rather than just "trying to continually
> > open the file with FileShare.None, and ignoring a particular
exception"??
>
> Yes : find why the file could not be access :)
> Which proces can use it ?
>
> --
> LEBRUN Thomas
> http://morpheus.developpez.com
>
>
> "gregory_may" <None> wrote in message
> news:uGB5hXbdEHA.1652@TK2MSFTNGP09.phx.gbl...
> > http://msdn.microsoft.com/msdnmag/issues/01/07/vbnet/default.aspx
> >
> >
> > Hi,
> >
> > I have created a batch file router using the filesystemwatcher
componant.
> I
> > am facing the exact same issue as the link above. Does anyone have a
more
> > elegant solution to this problem rather than just "trying to continually
> > open the file with FileShare.None, and ignoring a particular
exception"??
> >
> >
> > Thanks!!!
> >
> >
>
>
begin 666 r.gif
M1TE&.#EA$ `0`(<``& @8& @<' H<( X@(!(D)! D)! H)!(H(=_M*!(L*!0
MH*!0L*!8L+!0L*!HL+!@L+!HL+!8P+!PP+!XP,!HP("(L):/M("(P("0P("0
MT)"0P):6PY"8P)"8T)VDQY"@T*"8P*6EPZ2DRZ"HP*"@T*"HT*"PT+"XT+#8
M\+#@_[#H_\" P," T,"(T-"8T-"@T-"HT/#0@/#8@/#0D/_@@/_H@/_@D/_H
MD/_HH/_HL/#PH/_PH/_PL/_XL,# T,# X,#8\,#@_\#H\,#H_]#P_^#0P.35
MY/_XP/__P/__T./E[^WB[>#H\.#H_^KJ\.KK\^WN]N#P\.#P_^#X_^#_____
MX/#P]O#P__#X__#_____\/___P``````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````````````"'Y! ```/\`+ `````0`! ```C%`+<('$BP($$H
M'D*$X,!!B4&!4$1HF5BE!X(G!B-.W*(E28\;")P<]%"E"L4C.VK0L&!E8 D<
M,''8L"$CALT9&UR:0(*D1P\>.6#F\#'"I9 ..CZ4,''B1!$?$$X,_$ %!8DH
M4[!<8?)#@@&I`CNHZ! ERY2S32:\. #A`8,$'#)(P7)V"I,),%RT8+%B@@`-
M0(@,29$BB(,7+"A$:+# 0 `,D"]<J* !! $%$18D*# `P,,M1@(8`$":].<M
*2TR?)IB:8$ `.P``
`
end
- Next message: mikeb: "Re: Reg Compilers"
- Previous message: bruce barker: "Re: event handling with user controls"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|