Home › Forums › .NET libraries › Xceed SFTP/FTP for .NET › How to abort a diskfile and ftpfile file upload?
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?
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by tomer (had 3105 views)
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 :
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by André (had 320 views)
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
According to the blog, the error rasied inside the bytesprogression should be raised on the source.copyto level.
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by tomer (had 1927 views)
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 :
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by André (had 3252 views)