473,761 Members | 10,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

knowing when file has been totally transferred

let's say I'm transferring a large file like 100MB over to a folder.

The program detects when the file arrives. However, I can't
figure out how to know when the file is totally transferred over.

One unsuccessful method is to...

dim fi as new fileinfo(newfil e)

fi.length returns the supposed size of the file. But it correctly
reports the final size of the file the moment transferring
starts. So that's no help at all.

I want to know what the file is totally transferred to the folder
so I can then begin to work on it. Any ideas?

Apr 17 '06 #1
7 2048
Well i would do the following

i would use a filesystem watcher to detect the arrival of the file (
Created event ) this event will fire as soon as the transfer starts
however it will also provide us the location and name of the file so we can
wait in a loop untill we can get exclusive access to the file
when this is possible we know that the file is completely transfered

regards

Michel Posseth [MCP]

"chad" <ch**@discussio ns.microsoft.co m> schreef in bericht
news:E0******** *************** ***********@mic rosoft.com...
let's say I'm transferring a large file like 100MB over to a folder.

The program detects when the file arrives. However, I can't
figure out how to know when the file is totally transferred over.

One unsuccessful method is to...

dim fi as new fileinfo(newfil e)

fi.length returns the supposed size of the file. But it correctly
reports the final size of the file the moment transferring
starts. So that's no help at all.

I want to know what the file is totally transferred to the folder
so I can then begin to work on it. Any ideas?

Apr 17 '06 #2
uhm..... what method do you use when you wanna find out if we get exclusive
access to the file?

"Michel Posseth [MCP]" wrote:
Well i would do the following

i would use a filesystem watcher to detect the arrival of the file (
Created event ) this event will fire as soon as the transfer starts
however it will also provide us the location and name of the file so we can
wait in a loop untill we can get exclusive access to the file
when this is possible we know that the file is completely transfered

regards

Michel Posseth [MCP]

"chad" <ch**@discussio ns.microsoft.co m> schreef in bericht
news:E0******** *************** ***********@mic rosoft.com...
let's say I'm transferring a large file like 100MB over to a folder.

The program detects when the file arrives. However, I can't
figure out how to know when the file is totally transferred over.

One unsuccessful method is to...

dim fi as new fileinfo(newfil e)

fi.length returns the supposed size of the file. But it correctly
reports the final size of the file the moment transferring
starts. So that's no help at all.

I want to know what the file is totally transferred to the folder
so I can then begin to work on it. Any ideas?


Apr 17 '06 #3

open the file in a try catch block and use
FileShare.None as the share parameter to a FileStream object

you might wrap this in a nice function

regards

Michel Posseth [MCP]
"chad" <ch**@discussio ns.microsoft.co m> schreef in bericht
news:57******** *************** ***********@mic rosoft.com...
uhm..... what method do you use when you wanna find out if we get
exclusive
access to the file?

"Michel Posseth [MCP]" wrote:
Well i would do the following

i would use a filesystem watcher to detect the arrival of the file (
Created event ) this event will fire as soon as the transfer starts
however it will also provide us the location and name of the file so we
can
wait in a loop untill we can get exclusive access to the file
when this is possible we know that the file is completely transfered

regards

Michel Posseth [MCP]

"chad" <ch**@discussio ns.microsoft.co m> schreef in bericht
news:E0******** *************** ***********@mic rosoft.com...
> let's say I'm transferring a large file like 100MB over to a folder.
>
> The program detects when the file arrives. However, I can't
> figure out how to know when the file is totally transferred over.
>
> One unsuccessful method is to...
>
> dim fi as new fileinfo(newfil e)
>
> fi.length returns the supposed size of the file. But it correctly
> reports the final size of the file the moment transferring
> starts. So that's no help at all.
>
> I want to know what the file is totally transferred to the folder
> so I can then begin to work on it. Any ideas?
>
>
>


Apr 17 '06 #4
Another option is to save the file using a temporary name and then
rename it to the final destination name. That way the
FileSystemWatch er would key on the rename event and you would catch the
file after it was completely transferred.

Apr 18 '06 #5
thanks guys. that helped a lot :-)
Apr 19 '06 #6
There may be others but one sure-fire way to determine if a file is
available for use is to attempt to open it for exclusive access.

If the attempt fails then it is NOT available.

If the attempt succeeds then it IS available.

The sort of logic you need to do this is (pseudo-code):

Catch the 'Create' event from FileSystemWatch er

While True
Try
Attempt to open the file for exclusive use
....
If the logic gets to here then it succeeded so do whatever you want to
do with the file
....
Exit While
Catch ex As Exception
Check the exception
If it is not the exception that tells us that the file is not
available then deal with it
....
Exit While
End If
If the logic gets to here then the file is not available so allow the
loop to continue
End Try
End While
"dan m" <dan m@discussions.m icrosoft.comwrote in message
news:B5******** *************** ***********@mic rosoft.com...
>I am little confused on when and how to rename the originial file and still
get the entire download file. I have filesystemwatch er running on my
server.
If I fire the create event of the watcher don't i still have only a
partial
downloaded file? Does the rename event only fire when the file is
completely
downloaded?

Thanks for any help.
Dan
"Chris Dunaway" wrote:
>Another option is to save the file using a temporary name and then
rename it to the final destination name. That way the
FileSystemWatc her would key on the rename event and you would catch the
file after it was completely transferred.


Jan 15 '07 #7
I have used the code below to determine when a file upload is finished
before making a thumbnail of the file. It has always worked for me. It
appears that the file.exists does not equal to true until the file has been
totally uploaded.
Dim fi As New System.IO.FileI nfo(Server.MapP ath(".") & "\Photos\" &
FileUpload1.Fil eName)
Do While fi.Exists = False
'do nothing
Loop
"dan m" <dan m@discussions.m icrosoft.comwrote in message
news:B5******** *************** ***********@mic rosoft.com...
>I am little confused on when and how to rename the originial file and still
get the entire download file. I have filesystemwatch er running on my
server.
If I fire the create event of the watcher don't i still have only a
partial
downloaded file? Does the rename event only fire when the file is
completely
downloaded?

Thanks for any help.
Dan
"Chris Dunaway" wrote:
>Another option is to save the file using a temporary name and then
rename it to the final destination name. That way the
FileSystemWatc her would key on the rename event and you would catch the
file after it was completely transferred.


Jan 15 '07 #8

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

Similar topics

3
2314
by: Marcus | last post by:
Hi all, Quick question... I have a class that is over 1200 lines of code and 50 KB in size. This file does not display any html, it is just included and after I call all the necessary functions, I save the data and display it on my output page. Here is my confusion - to the best of my understanding, since php is server side, this file should never be "transferred" to the client, correct? In other words, whether my class is 100 lines...
2
1776
by: Jason | last post by:
Hi folks. I'm running into a problem figuring out how to proceed with the following. I have files being transferred from several machines through a separate sftp (SSH) connection to a server. I need to have a program running on my server, developed in VB6, that parses these files and inserts them into a database. The problem I'm running across is finding out the best way to see if the files have been totally transferred, as I don't...
8
3038
by: IGC | last post by:
I have a requirement to record in a database when a file is finished downloading to the end-user. Currently when a user clicks a download icon for a file it directs to an ASP page that records the "hit" into a database, then I use a response.redirect "filename.exe" to point the user to the download. What I'm missing is knowing when the download is complete so I can update the database to show the file successfully completed its download....
9
9376
by: Ian Richardson | last post by:
If I follow the steps on http://www.dhtmlcentral.com/tutorials/tutorials.asp?id=11 to add .js files to a document on demand, let's say by <body onload="blah();">, how can I reliably tell that it has been loaded? BTW, I'm doing this for several .js files (and I don't always know how many I'll be loading), so I need to check them all. If I code for IE, I can check all the document.scripts.readyState values (not being "uninitialized" or...
5
3956
by: JS | last post by:
I have v8.1 fix 5 installed on windows 2k. I compiled a stored procedure in development environment, then used the get routine command to generate the file. I transferred the file to second test environment with same fixpack level, but no compiler or development environment installed. I issued put routine in second test environment and command succeeded but when i try and run the stored proc with call command, db2 comes back with sql0444...
3
2765
by: Shmulik | last post by:
I have an application written in C# that creates a queue of items to process, connects via a TCP connection to a server on a Unix box, and then passes data files to the Unix box for processing (cluster) - normally this works fine. However, on the front end, another Unix system generates and transfers files to the DotNet application (Management system/controller) and recently I've witnessed the following: 1) Unix Box "A" generates data...
30
2073
by: Franck PEREZ | last post by:
Hello, I'm developing a small XML marshaller and I'm facing an annoying issue. Here's some sample code: ########### My test application ############ class Foo(object): #The class I'd like to serialize pass
6
2714
by: Jatin | last post by:
Hey Guys I have a web application that allows users to download files. But the files are not hosted on the webserver. The files are stored on external servers and are referenced by a URL/URI. Since my application restricts the number of downloads for the file per user, i cannot show the user the URL/URI of the server hosting the file. Therefore i need to some how route the file via my webserver, and then use the Response to stream the...
9
5211
by: Adi | last post by:
Hello eveyone, I wanna ask a very simple question here (as it was quite disturbing me for a long time.) My problem is to read a file line by line. I've tried following implementations but still facing problems: Assume that FILE* filePointer; unsigned char lineBuffer;
0
9345
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
10115
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...
1
9905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9775
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...
1
7332
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5229
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.