473,382 Members | 1,368 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,382 software developers and data experts.

How to ensure that a file has been received completely before reading it?

How can i ensure that i have received a file completely from an external source before reading it?Suppose i am receiving a file from an external source and i try to read the file before i have recieved the entire file.How can i ensure that this does not happen?
Jul 10 '08 #1
6 1514
JosAH
11,448 Expert 8TB
This question was about to get lost in the .NET Articles section, so I saved it from
drowning ;-)

kind regards,

Jos (moderator)
Jul 10 '08 #2
Plater
7,872 Expert 4TB
Check the size of the file in bytes and make sure they are all there first?
Jul 10 '08 #3
developing
110 100+
where are you getting it from?

depending on the download source, it might supply a checksum.
if you control the download source, then supply a checksum before you begin the file download (md5 for sha1)

then when the download has been inactive for 5 seconds, check the file against the checksum. If it matches, download is complete.

If it doesn't, then either the file is corrupted or download isn't complete yet
Jul 10 '08 #4
I guess i need to explain the situation a bit more.[:)]

I have this windows service running that polls certain folders for text and xml files received from an external source.Now the service should process only those files that have been received completely.Currently what is happening is that, whenever a huge file comes in the service tries to process it before it has been received completely.There's no way to know the size or the contents of the file beforehand.Is there any way in which i can check if the file has been received completely?
Jul 11 '08 #5
Plater
7,872 Expert 4TB
Hmm, you *might* be able to get away with trying to open the file for full read/write access, and saying don't share ANY access.
My theory is that if the file is not finished "arriving", then something will still have a handle open to it. So your request for full rights with no sharing would fail if something else has it open?

You could also poll for modified times and see when it's stopped changing for more then X amount of time?
Jul 11 '08 #6
developing
110 100+
how do you read the file? like after every hour or so....or is it event driven?
Jul 12 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: A.M. | last post by:
Hi at all, how can I do to insert into a HTML page a file .txt stored in the same directory of the server where is the html file that must display the text file.txt? Thank you very much P.Pietro
3
by: Lars | last post by:
Hi! I´m trying to send a file over a network with tcp/ip so that the client can download it and save it. I going to send the size of the file in a textmessage but I have not implemented that...
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...
1
by: Henk | last post by:
Hi, I have a problem with sending a file. I have a client application that connects to a server and sends the string "data". Then it sends a file. If the server receives "data", the method...
9
by: Mark | last post by:
Hi all, This is something which has been bugging me for ages. How can I check if a file is already in use by a different program? It doesn't seem to matter which mode I pass to fopen, it will...
7
by: random guy | last post by:
Hi, I'm writing a program which creates an index of text files. For each file it processes, the program records the start and end positions (as returned by tellg()) of sections of interest,...
4
by: tshad | last post by:
I have a filewatcher program that tells me that a file has been created in my folder. The problem I want to immediately move the file or access it. If the file is large, it not be completely...
1
by: shyaminf | last post by:
hi everybody! iam facing a problem with the transfer of file using servlet programming. i have a code for uploading a file. but i'm unable to execute it using tomcat5.5 server. kindly help me how to...
15
by: =?ISO-8859-15?Q?L=E9na=EFc?= Huard | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all, For some reasons, somewhere in a program, I'd like, if possible, to quickly parse a whole file before rewinding it and letting the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.