Hi Doug
I ran into the same problem in my filewatcher. I made a function that
checked if the file was open
if the function was true then it waited and then tried again until the file
was ready.
Private Function isFileOpen(ByVal filename As String) As Boolean
Dim sf As System.IO.FileStream
Try
sf = System.IO.File.Open(filename, System.IO.FileMode.Open,
System.IO.FileAccess.ReadWrite, System.IO.FileShare.None)
Return False
Catch ex As System.IO.IOException
Return True
ex = Nothing
Finally
'
If Not IsNothing(sf) Then
sf.Close()
sf = Nothing
End If
End Try
End Function
And in the code do an DO loop as follow
Do
System.Threading.Thread.Sleep(500)
Loop While wfile.Exists(file_name) And isFileOpen(file_name)
I hope this helps
Petter L.
"Patrice" <no****@nowhere.com> wrote in message
news:OC**************@TK2MSFTNGP14.phx.gbl...
Not familiar with it but what if you check the changed event ? Also once
you
have no more changed event for a period of time you could perhaps try to
open the file with an exclusive lock for an additonal check.
Patrice
--
"Doug R" <Do***@discussions.microsoft.com> a écrit dans le message de
news:8A**********************************@microsof t.com... Hello,
I could use a little help from you Gurus out there. I have an aplication
that watches a directory and detects when a PGP encrypted file lands in
the directory and starts a process that decrypts it and parses the resulting
contents. I am using the FileSystemWatcher's Created event to detect
when
the file arrives. The problem I have is that these files are large(5-10
megs) and they are being transfered over a limited pipe. I don't want to
start the decryption and parsing until they are done downloading but I
can't seem to find a straightforward way of sorting out when that is. The
FileSystemWatcher Created event fires off as soon as the file starts to
hit the directory and it kicks off my other processes to early.
Does anyone have a way to determine when the file is done loading?
(note - I have no idea how long the file will take to download or how big it may
be.)
Thanks for any help,
Doug