DownloadFile Arithmetic operation resulted in an overflow

This forum is not monitored by the SmartFTP staff. If you have a license please contact technical support by email.
NemisisJedi
Posts: 8
Joined: Fri Nov 28, 2008 11:46 am

DownloadFile Arithmetic operation resulted in an overflow

Post by NemisisJedi » Fri Nov 28, 2008 12:16 pm

I am using the DownloadFile function via a FTPConnectionMTA and i am getting the following error on this bit of code

ERROR = Arithmetic operation resulted in an overflow.

CODE
mFtp.DownloadFile("REMOTEFILENAME", "LOCALFILENAME", 2148751482, 0)

I am resuming a download of a file that has a remoteSize of 7243113984

Does anyone know why this is happening? I believe that the download is failing as the input is an integer data type which is a max value of 2147483647, and my value is above it. Is this a bug? Should it be a long data type instead of an integer??

Thanks for your help in advanced.

mb
Posts: 12030
Joined: Thu Oct 11, 2001 1:24 pm
Display name: Mat (SmartFTP)
Contact:

Re: DownloadFile Arithmetic operation resulted in an overflow

Post by mb » Fri Nov 28, 2008 1:32 pm

What programming language are you using?

NemisisJedi
Posts: 8
Joined: Fri Nov 28, 2008 11:46 am

Re: DownloadFile Arithmetic operation resulted in an overflow

Post by NemisisJedi » Fri Nov 28, 2008 1:40 pm

Vb.NET

mb
Posts: 12030
Joined: Thu Oct 11, 2001 1:24 pm
Display name: Mat (SmartFTP)
Contact:

Re: DownloadFile Arithmetic operation resulted in an overflow

Post by mb » Fri Nov 28, 2008 1:42 pm

Can you post a bit more of the code? Or do you use the numeric 2148751482 in the arguments?

NemisisJedi
Posts: 8
Joined: Fri Nov 28, 2008 11:46 am

Re: DownloadFile Arithmetic operation resulted in an overflow

Post by NemisisJedi » Fri Nov 28, 2008 1:49 pm

The value 2148751482 is being passed into the DownloadFile procedure. My code looks like

mFtp.DownloadFile(pRemoteFile, pLocalFileInfo.FullName, pLocalFileSize, 0)

pRemoteFile = Remote File Name
pLocalFileInfo = FileInfo where localfile is to be saved
pLocalFileSize = Long value, containing the length of the file held locally, so a resume download can be done

mb
Posts: 12030
Joined: Thu Oct 11, 2001 1:24 pm
Display name: Mat (SmartFTP)
Contact:

Re: DownloadFile Arithmetic operation resulted in an overflow

Post by mb » Fri Nov 28, 2008 1:53 pm

You have to split the position into 2 32-bit longs. In C# this looks something like that:
DownloadFile(source, dest, (int)pLocalFileSize, (int)(pLocalFileSize >> 32))

NemisisJedi
Posts: 8
Joined: Fri Nov 28, 2008 11:46 am

Re: DownloadFile Arithmetic operation resulted in an overflow

Post by NemisisJedi » Fri Nov 28, 2008 1:56 pm

Ok, so i do not need to pass a 0 in as the last parameter, even if i am/am not doing a resume?

mb
Posts: 12030
Joined: Thu Oct 11, 2001 1:24 pm
Display name: Mat (SmartFTP)
Contact:

Re: DownloadFile Arithmetic operation resulted in an overflow

Post by mb » Fri Nov 28, 2008 2:09 pm

It depends on what position you resume.

NemisisJedi
Posts: 8
Joined: Fri Nov 28, 2008 11:46 am

Re: DownloadFile Arithmetic operation resulted in an overflow

Post by NemisisJedi » Fri Nov 28, 2008 2:20 pm

I would like to resume at the end of the local file, if the local file exists, else it starts from the beginning

mb
Posts: 12030
Joined: Thu Oct 11, 2001 1:24 pm
Display name: Mat (SmartFTP)
Contact:

Re: DownloadFile Arithmetic operation resulted in an overflow

Post by mb » Fri Nov 28, 2008 2:23 pm

If the local file doesn't exist you use 0,0 for the arguments otherwise you use the method I described in my last post:
DownloadFile(source, dest, (int)pLocalFileSize, (int)(pLocalFileSize >> 32))

Regards,
Mat

Post Reply