Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
9.2k views
in .NET FTP by
Hi. I am having a problem with resume. I am testing my appilcation by disabling the internet during download so I can test resuming. I am transferring a binary file using the Get(stream, string) method.

Here is my transfer function. It gets called everytime a socket exception is thrown.


StreamWriter destinationStream = new StreamWriter(to,true);

try
{
  ftp.Resume();
  ftp.Get(destinationStream.BaseStream, from);
  return true;
}
catch(Exception ex)
{
  if(destinationStream.BaseStream.CanWrite)
      destinationStream.Close();
  destinationStream = null;
  return false;
}




If this returns false, I quit the ftp connection and reconnect, then run the above function again. The resume does not appear to work however. I was downloading a 64 mb file and the resulting file came out as 208mb. I think the resume actually starts at the beginning of the file again and appends. on resume, the ftp command REST 0 gets called instead of REST filesize.

6 Answers

0 votes
by
I tried the Get(string, string) method instead of Get(stream, string). The Get(string, string) method does resuming correct. However, as per my post yesterday, it throws the wrong exception when the connection is disrupted. The exception says "file us in use by another process" (sic).
0 votes
by (162k points)
What do you mean, 'throws the wrong exception'?

BTW, are you using 1.1.1 or 1.1.0?

It would seem that the local file stream is not being closed, which is why next time around it thinks it is in use (and is 0 bytes in size).

1.1.1 does change the exception handling a little which should help here.

I tried the Get(string, string) method instead of Get(stream, string). The Get(string, string) method does resuming correct. However, as per my post yesterday, it throws the wrong exception when the connection is disrupted. The exception says "file us in use by another process" (sic).
0 votes
by
I do have 1.1.1.

By "wrong exception" I mean that a socket exception should be thrown when the connection is lost, not one with "file is use". The socket exception is thrown when using Get(stream, string).


I guess you do not have these issues... do you have any sample code thatuse use for testing the resume? Thanks for the help.
0 votes
by (162k points)
We don't actually throw this exception - .NET does.

We'll look into this a bit further.

I do have 1.1.1.

By "wrong exception" I mean that a socket exception should be thrown when the connection is lost, not one with "file is use". The socket exception is thrown when using Get(stream, string).


I guess you do not have these issues... do you have any sample code thatuse use for testing the resume? Thanks for the help.
0 votes
by
Yes, I figured. I was just curious as to why the 2 methods returned different exceptions. I'll look into it as well if I have time. Thanks.
0 votes
by (162k points)
We may have a fix for this. It should sort out the ""file is use" error.

If you email support at enterprisedt dot com we'll send you a new distro to try out.

Yes, I figured. I was just curious as to why the 2 methods returned different exceptions. I'll look into it as well if I have time. Thanks.

Categories

...