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?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

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
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
    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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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

The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

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.
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.

Lookes tobe the above site inaccessible
Sorry, There seems to be a problem with his server. If you want, I can e-mail some info.
saltacidAuthor Commented:
Thank you for the answer,
but I'm looking for an example how to use those commands...
such as SIZE, QUOTE...
   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.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.