FTP file size

I have developed small FTP program. Currently, I just download the file without details info of the files.
My question is how to get the size of the file to be downloaded and the size of file after  downloaded?
saltacidAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
GeorgeKConnect With a Mentor Commented:
Some more detail about what you have tried and what exactly you want to do would be useful. However the following may be what you are looking for. I am currently do the same task.

1) In VB to find the file size of your local file (before you open it for sending) use the VB command
   FileLen([path-file])
2) When your application communicates with the Remote server Host, the FTP command (if your remote server supports it)is SIZE [path-file] eg.
    SIZE myfile.txt
or
    SIZE /home/saltacid/myfile.exe
If you require this info for you program to pick up the reply from the remote server, the likely replies are;
    213 [bytes]
for example
    213 1422
and if there is an error (ie file not found)
    550 [path-file]: is not a plain file.
for example (if the file does not exist)
    550 /home/saltacid/myfile.exe: is not a plain file.

This is important to verify (with some degree) the file has been transfered without corruption.

0
 
mark2150Commented:
The LS command will give you a directory of the remote system. All the info you need should be in there. Once the file is local getting the filesize is just the FileLen command or LOF() if the file is open.

M
0
 
mcriderCommented:
send "QUOTE SIZE filename" to the remote FTP Server.

It will respond with a 213 message that has the filesize in bytes.  for example, the file you are going to download is called TFILE and is 524 bytes long... You send "QUOTE SIZE TFILE" and the server will return:

213 524


Cheers!
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
kbalarajuCommented:
I tried to use Send command with Inet1.execute. But I do not know how to catch the returned values. Could you please give an example with complete command.
-Raju
0
 
MoMarviCommented:
There is a great free control that will do alot of this, and more, (such as status of the dowload, great for larger files.) Go to http://www.fp.gvn.net/bradley/xFtp/xftpprod.htm

I have no personal stake in it, but it beats the M$ Inet control hands down.

0
 
kbalarajuCommented:
Lookes tobe the above site inaccessible
0
 
MoMarviCommented:
Sorry, There seems to be a problem with his server. If you want, I can e-mail some info.
0
 
saltacidAuthor Commented:
Thank you for the answer,
but I'm looking for an example how to use those commands...
such as SIZE, QUOTE...
0
 
GeorgeKCommented:
saltacid,
   I would like to know how you are communicating with the FTP server. I am using a control by a company called Catalyst. It is good but I am still having difficulties myself.

    The Catalyst control I am using allows me to send text messages to the remote FTP host via an FTP port so my code would like;
'Login code
' lots of code here

'Send size request to FTP server here
strMsg = "SIZE /user/saltacid/tst.txt"
ClientSocket.SendLen = len(strMsg)
ClientSocket.SendData = strMsg

    What I am trying to say, if you have established a data connection to an FTP server you should be able to send it a request message, that is "SIZE filename" but if you are using a high level FTP control then it may have a particular command set which maybe SIZE is not a support command.

   So, please if you have written an FTP program, how does it communicate to the FTP server (if it is a client) or the FTP client (if it is a server that you have written. Then maybe I could suggest something specific.

    As for QUOTE, I have not seen this command.


0
All Courses

From novice to tech pro — start learning today.