473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How do you detect when a file is finished being created

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
Jul 21 '05 #1
4 3703
On the old unix systems I would check the filesize in a loop, filesize ==
same after a few times I figured the file was complete. I'm sure .NET has
some class, methods to do this?

"Doug R" <Do***@discussions.microsoft.com> wrote in message
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

Jul 21 '05 #2
I was hoping to avoid that aproach if I could. Part of the problem with it
is that the downloads can temporarily stall causing a false positive. That
would also require me to build it as a multithreaded system and it is quite
happily single threaded at the moment.

"Jim Douglas" wrote:
On the old unix systems I would check the filesize in a loop, filesize ==
same after a few times I figured the file was complete. I'm sure .NET has
some class, methods to do this?

"Doug R" <Do***@discussions.microsoft.com> wrote in message
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


Jul 21 '05 #3
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

Jul 21 '05 #4
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


Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Cédric | last post by:
Hi, I have some problems to detect when a file is changed by another application (the file is changed several times by the application). Sometimes, it is correctly detected, sometimes not. I...
6
by: Kiran | last post by:
Hi, I have program, which opens file at the startup and logs error messages to the file, file handle is closed at the end of the program. However if file is deleted in-between, program do not...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
4
by: Doug R | last post by:
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...
0
by: timbobd | last post by:
Using Visual Basic .NET 2003, I have created a combobox with custom code for "autocomplete" functionality and to trigger a DropDown event when the user starts typing. I want to do a database lookup...
2
by: Jason S | last post by:
Hi there, I created a simple VB app that runs in the background that I now need to detect when Windows (XP with SP2) is just about to Shut Down OR the user is Logging Off. Is this possible? I...
0
by: Andrew | last post by:
In the Component I am developing I need to know when the IDE has finished loading the form at design time. Is there an event I can receive to know when the IDE has finished opening the form at...
10
by: Martin Arvidsson, Visual Systems AB | last post by:
Hi! I want to create an event that is fiered when a file is accessed (Opened). What i want to do is monitor a directory and subdirectory if files are opened. I have tried to use the...
0
by: Gimble | last post by:
Does anyone know of a way to detect when an AJAX call has finished updating a page in the webbrowser control in a vb.net program? For example, if I click "next" on a page and that causes a table...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.