This documentation is archived and is not being maintained.

FtpWebRequest.Abort Method

Terminates an asynchronous FTP operation.

Namespace:  System.Net
Assembly:  System (in System.dll)

Public Overrides Sub Abort
Dim instance As FtpWebRequest


If there is no operation in progress, this method does nothing. If a file transfer is in progress, this method terminates the transfer.


This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing.

The following code example demonstrates how the user can terminate an asynchronous upload of a file from the local directory to the server.

No code example is currently available or this language may not be supported.
    void AbortUpload(String* fileName, String* serverUri)
        request = dynamic_cast<FtpWebRequest*>(WebRequest::Create(serverUri));
        request->Method = FtpMethods::UploadFile;

        // Get the file to be uploaded and convert it to bytes.
        StreamReader* sourceStream = new StreamReader(fileName);
        fileContents = Encoding::UTF8->GetBytes(sourceStream->ReadToEnd());

        // Set the content length to the number of bytes in the file.
        request->ContentLength = fileContents->Length;

        // Asynchronously get the stream for the file contents.
        IAsyncResult* ar = request->BeginGetRequestStream(
            new AsyncCallback (this, &AsynchronousFtpUpLoader::EndGetStreamCallback), 
        Console::WriteLine(S"Getting the request stream asynchronously...");  

        Console::WriteLine(S"Press 'a' to abort the upload or any other key to continue");
        String* input = Console::ReadLine();
        if (input->Equals(S"a"))
            Console::WriteLine(S"Request aborted");


Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0