Solved

Get/Put file To/From FTP server

Posted on 2004-09-21
5
257 Views
Last Modified: 2010-05-02
Dear All,

I have two windwo applications A & B running on different PCs.

Application A: put a file to FTP server.
Application B: get this file FTP server.

How can I prevent Application B to get a file which is being uploaded to FTP server by Application A?

I think uploading a dummy file may be useful. Any good idea?

Thanks!
0
Comment
Question by:cplau
5 Comments
 

Author Comment

by:cplau
ID: 12111959
In getting a file, can I check this file is being modified by someone else?
0
 
LVL 4

Accepted Solution

by:
Glowman earned 125 total points
ID: 12112058
Cplau,
What I do is do a loose loop checking file size every few seconds depending on the connection rate use InternetFindNextFile to loop through the files in the FTP directory, and then using the WIN32_FIND_DATA to determine if the nFileSizeLow has changed, if it hasn't after a try or two the file up there is done being uploaded.  There must be a way to tell if the file is in a change state but I couldn't figure it out so I did it this way.  Got more code if you want it.
G
0
 
LVL 5

Expert Comment

by:abith
ID: 12112314
hi
there is a one way.  keep a index file in which weather the new has been upload completely or not.

Assume that if the A application is sending the file before sending the file create a file in the A server and set a flag to 0.  after completion set the flag to 1.

And b applicaiton can open the application and check the status.  and if the get is done the line can be deleted.

Else you have to go for the port connection method,

Regards
Abith
0
 
LVL 14

Expert Comment

by:aelatik
ID: 12112605
You could PUT the file starting with a special character like "~FILENAME.BIN".
When finished rename the file to "FILENAME.BIN"

And in your GET program don't dowload files starting with "~"
0
 
LVL 14

Expert Comment

by:aelatik
ID: 12112650
Or in your GET program, do a rename test before downloading to test if the file is in use. for example :

RENAME FILENAME.EXE TESTFILENAME.EXE
 ' Check if error occurs, if not RENAME it back and dowload
RENAME TESTFILENAME.EXE FILENAME.EXE
GET FILENAME.EXE C:\FILENAME.EXE
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question