DownloadFile Arithmetic operation resulted in an overflow

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.

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.

What programming language are you using?


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

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

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

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

It depends on what position you resume.

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

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


The code seems to be moving along further now, but i am now getting the same error "Arithmetic operation resulted in an overflow." with the value of 7280103424.

I have changed my code to the following

downloadStatus = mFtp.DownloadFile(pTargetFile, localFile.FullName, CInt(localFileSize), CInt((localFileSize >> 32)))

Is DownloadFile the best download method to use, what is the difference with DownloadFile and DownloadFileEx and DownloadFileEx2??

DownloadFileEx2 seems to allow for Long datatype inputs, but i am not sure what the CreateDeposition parameter means and what i should pass in for it??

Try something like this for the 3rd argument:
CInt(localFileSize & 0xffffffff)

That works perfectly, thanks