473,715 Members | 6,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 FileSystemWatch er'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
FileSystemWatch er 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 3725
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***@discussi ons.microsoft.c om> wrote in message
news:8A******** *************** ***********@mic rosoft.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 FileSystemWatch er'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
FileSystemWatch er 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***@discussi ons.microsoft.c om> wrote in message
news:8A******** *************** ***********@mic rosoft.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 FileSystemWatch er'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
FileSystemWatch er 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***@discussi ons.microsoft.c om> a écrit dans le message de
news:8A******** *************** ***********@mic rosoft.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 FileSystemWatch er'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
FileSystemWatch er 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(ByVa l filename As String) As Boolean

Dim sf As System.IO.FileS tream

Try

sf = System.IO.File. Open(filename, System.IO.FileM ode.Open,
System.IO.FileA ccess.ReadWrite , System.IO.FileS hare.None)

Return False

Catch ex As System.IO.IOExc eption

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.Threadin g.Thread.Sleep( 500)

Loop While wfile.Exists(fi le_name) And isFileOpen(file _name)

I hope this helps

Petter L.

"Patrice" <no****@nowhere .com> wrote in message
news:OC******** ******@TK2MSFTN GP14.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***@discussi ons.microsoft.c om> a écrit dans le message de
news:8A******** *************** ***********@mic rosoft.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 FileSystemWatch er'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
FileSystemWatch er 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
1368
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 maybe expect an access problem. Can it be? And how to solve it? Below is a part of my code (written in C#). Is there anybody who can help me? .... FileSystemWatcher watcher = new FileSystemWatcher();
6
5296
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 report any error while writing to the open file handle. On Windows, file shows-up again in explorer and automatically deleted finally when program ends. On Unix, same thing happens if file is on nfs mounted drive, but in this case, actual file is...
1
5389
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 completely/succsessfully on the client's computer before updating some metadata on the server (file downloaded date for instance) However, All examples i have tried, and all examples I have found that other people says works - doesn't work for me :-(
4
319
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 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...
0
1074
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 after the user has selected a new value. However, since this can query hundreds of rows, I don't want to do a lookup every time the user types a character and autocomplete finds a new row in the list, I only want to do this when the user has...
2
11758
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 require my app to either pause the shutdown/log-off process for a few seconds whilst it does something important (it's a security thing). As soon as its finished, Windows should resume logging off the user and/or shutting down. Thanks in advance.
0
1191
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 design time? -- Andrew Cutforth - AJC Software - www.ajcsoft.com The best folder synchronize and directory compare tool available. AJC Active Backup instantly archives every file you edit giving you
10
5606
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 FileSystemWatcher. But it didn't work as i expected. I cant get it to fire an event when a file is accessed.
0
1260
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 on the page to reload, is there a way to know when that page section has finished loading?
0
8823
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9343
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9198
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9047
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7973
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
3175
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2119
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.