Home Forums .NET libraries Xceed SFTP/FTP for .NET How to abort a diskfile and ftpfile file upload?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #21171 |

    I have a simple file upload.  i open an ftpfile, and open a file with diskfile.  Then I do a diskfilevar.copyto with events being triggered.

    I want to let the user abort a large file upload in the middle.  How do i do that?

    Thanks,

    Tomer

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by tomer (had 3105 views)

    User (Old forums)
    Member
    Post count: 23064

    There is no abort feature for the FileSystem, and there is not asynchronous copy/move methods either, so it can only be done through exceptions. 

    You can look at the following blog, it explains how to do it with a zip file, you can do something similar with an FtpFile :

    http://blogs.xceedsoft.com/plantem/PermaLink,guid,cff8fc14-76a1-4fde-a4f0-a49ab582a21a.aspx

     

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by André (had 320 views)

    User (Old forums)
    Member
    Post count: 23064

    I placed a throw new applicationexception(“user abort”)

    This i placed inside the byte progression.

    But the erorr is rasied inside my routine, and not at the copyto level in my main application.  this is even though the copyto has an on error resume next before:

    on error resume next

    source.copyto….

     

    According to the blog, the error rasied inside the bytesprogression should be raised on the source.copyto level.

     

    tomer

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by tomer (had 1927 views)

    User (Old forums)
    Member
    Post count: 23064

    I don’t know why it behaves this way, but it works fine here.  The problem may come from using the “on error resume” statement.  Using a try/catch block, as shown in the blog, should work fine.

    I suggest you look at the links provided in the following post, which discusses “on error” vs “try/catch” blocks :

    http://www.codeguru.com/forum/showthread.php?threadid=398008

    http://www.codeguru.com/forum/showthread.php?t=383057

     

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by André (had 3252 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.