FtpWebRequest 類別

定義

實作檔案傳輸通訊協定 (FTP) 用戶端。Implements a File Transfer Protocol (FTP) client.

public ref class FtpWebRequest sealed : System::Net::WebRequest
public sealed class FtpWebRequest : System.Net.WebRequest
type FtpWebRequest = class
    inherit WebRequest
Public NotInheritable Class FtpWebRequest
Inherits WebRequest
繼承

範例

下列程式碼範例將示範如何從 FTP 伺服器刪除檔案。The following code example demonstrates deleting a file from an FTP server.

static bool DeleteFileOnServer( Uri^ serverUri )
{
   // The serverUri parameter should use the ftp:// scheme.
   // It contains the name of the server file that is to be deleted.
   // Example: ftp://contoso.com/someFile.txt.
   // 
   if ( serverUri->Scheme != Uri::UriSchemeFtp )
   {
      return false;
   }

   // Get the object used to communicate with the server.
   FtpWebRequest^ request = dynamic_cast<FtpWebRequest^>(WebRequest::Create( serverUri ));
   request->Method = WebRequestMethods::Ftp::DeleteFile;
   FtpWebResponse^ response = dynamic_cast<FtpWebResponse^>(request->GetResponse());
   Console::WriteLine( "Delete status: {0}", response->StatusDescription );
   response->Close();
   return true;
}
public static bool DeleteFileOnServer(Uri serverUri)
{
    // The serverUri parameter should use the ftp:// scheme.
    // It contains the name of the server file that is to be deleted.
    // Example: ftp://contoso.com/someFile.txt.
    //

    if (serverUri.Scheme != Uri.UriSchemeFtp)
    {
        return false;
    }
    // Get the object used to communicate with the server.
    FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
    request.Method = WebRequestMethods.Ftp.DeleteFile;

    FtpWebResponse response = (FtpWebResponse) request.GetResponse();
    Console.WriteLine("Delete status: {0}",response.StatusDescription);
    response.Close();
    return true;
}

下列程式碼範例將示範如何使用類別,從 FTP 伺服器下載檔案 WebClientThe following code example demonstrates downloading a file from an FTP server by using the WebClient class.

static bool DisplayFileFromServer( Uri^ serverUri )
{
   // The serverUri parameter should start with the ftp:// scheme.
   if ( serverUri->Scheme != Uri::UriSchemeFtp )
   {
      return false;
   }

   // Get the object used to communicate with the server.
   WebClient^ request = gcnew WebClient;

   // This example assumes the FTP site uses anonymous logon.
   request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" );
   try
   {
      array<Byte>^newFileData = request->DownloadData( serverUri->ToString() );
      String^ fileString = System::Text::Encoding::UTF8->GetString( newFileData );
      Console::WriteLine( fileString );
   }
   catch ( WebException^ e ) 
   {
      Console::WriteLine( e );
   }

   return true;
}
public static bool DisplayFileFromServer(Uri serverUri)
{
    // The serverUri parameter should start with the ftp:// scheme.
    if (serverUri.Scheme != Uri.UriSchemeFtp)
    {
        return false;
    }
    // Get the object used to communicate with the server.
    WebClient request = new WebClient();

    // This example assumes the FTP site uses anonymous logon.
    request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");
    try
    {
        byte [] newFileData = request.DownloadData (serverUri.ToString());
        string fileString = System.Text.Encoding.UTF8.GetString(newFileData);
        Console.WriteLine(fileString);
    }
    catch (WebException e)
    {
        Console.WriteLine(e.ToString());
    }
    return true;
}

下列程式碼範例將示範如何使用非同步作業,將檔案上傳到 FTP 伺服器。The following code example demonstrates using asynchronous operations to upload a file to an FTP server.

#using <System.dll>

using namespace System;
using namespace System::Net;
using namespace System::Threading;
using namespace System::IO;

public ref class FtpState
{
private:
   ManualResetEvent^ wait;
   FtpWebRequest^ request;
   String^ fileName;
   Exception^ operationException;
   String^ status;

public:
   FtpState()
   {
      wait = gcnew ManualResetEvent( false );
   }

   property ManualResetEvent^ OperationComplete 
   {
      ManualResetEvent^ get()
      {
         return wait;
      }

   }

   property FtpWebRequest^ Request 
   {
      FtpWebRequest^ get()
      {
         return request;
      }

      void set( FtpWebRequest^ value )
      {
         request = value;
      }

   }

   property String^ FileName 
   {
      String^ get()
      {
         return fileName;
      }

      void set( String^ value )
      {
         fileName = value;
      }

   }

   property Exception^ OperationException 
   {
      Exception^ get()
      {
         return operationException;
      }

      void set( Exception^ value )
      {
         operationException = value;
      }

   }

   property String^ StatusDescription 
   {
      String^ get()
      {
         return status;
      }

      void set( String^ value )
      {
         status = value;
      }

   }
};

public ref class AsynchronousFtpUpLoader
{
public:

   // Command line arguments are two strings:
   // 1. The url that is the name of the file being uploaded to the server.
   // 2. The name of the file on the local machine.
   //
   static void Main()
   {
      array<String^>^args = Environment::GetCommandLineArgs();

      // Create a Uri instance with the specified URI string.
      // If the URI is not correctly formed, the Uri constructor
      // will throw an exception.
      ManualResetEvent^ waitObject;
      Uri^ target = gcnew Uri( args[ 1 ] );
      String^ fileName = args[ 2 ];
      FtpState^ state = gcnew FtpState;
      FtpWebRequest ^ request = dynamic_cast<FtpWebRequest^>(WebRequest::Create( target ));
      request->Method = WebRequestMethods::Ftp::UploadFile;

      // This example uses anonymous logon.
      // The request is anonymous by default; the credential does not have to be specified. 
      // The example specifies the credential only to
      // control how actions are logged on the server.
      request->Credentials = gcnew NetworkCredential( "anonymous","janeDoe@contoso.com" );

      // Store the request in the object that we pass into the
      // asynchronous operations.
      state->Request = request;
      state->FileName = fileName;

      // Get the event to wait on.
      waitObject = state->OperationComplete;

      // Asynchronously get the stream for the file contents.
      request->BeginGetRequestStream( gcnew AsyncCallback( EndGetStreamCallback ), state );

      // Block the current thread until all operations are complete.
      waitObject->WaitOne();

      // The operations either completed or threw an exception.
      if ( state->OperationException != nullptr )
      {
         throw state->OperationException;
      }
      else
      {
         Console::WriteLine( "The operation completed - {0}", state->StatusDescription );
      }
   }

private:
   static void EndGetStreamCallback( IAsyncResult^ ar )
   {
      FtpState^ state = dynamic_cast<FtpState^>(ar->AsyncState);
      Stream^ requestStream = nullptr;

      // End the asynchronous call to get the request stream.
      try
      {
         requestStream = state->Request->EndGetRequestStream( ar );

         // Copy the file contents to the request stream.
         const int bufferLength = 2048;
         array<Byte>^buffer = gcnew array<Byte>(bufferLength);
         int count = 0;
         int readBytes = 0;
         FileStream^ stream = File::OpenRead( state->FileName );
         do
         {
            readBytes = stream->Read( buffer, 0, bufferLength );
            requestStream->Write( buffer, 0, bufferLength );
            count += readBytes;
         }
         while ( readBytes != 0 );
         Console::WriteLine( "Writing {0} bytes to the stream.", count );

         // IMPORTANT: Close the request stream before sending the request.
         requestStream->Close();

         // Asynchronously get the response to the upload request.
         state->Request->BeginGetResponse( gcnew AsyncCallback( EndGetResponseCallback ), state );
      }
      // Return exceptions to the main application thread.
      catch ( Exception^ e ) 
      {
         Console::WriteLine( "Could not get the request stream." );
         state->OperationException = e;
         state->OperationComplete->Set();
         return;
      }
   }

   // The EndGetResponseCallback method  
   // completes a call to BeginGetResponse.
   static void EndGetResponseCallback( IAsyncResult^ ar )
   {
      FtpState^ state = dynamic_cast<FtpState^>(ar->AsyncState);
      FtpWebResponse ^ response = nullptr;
      try
      {
         response = dynamic_cast<FtpWebResponse^>(state->Request->EndGetResponse( ar ));
         response->Close();
         state->StatusDescription = response->StatusDescription;

         // Signal the main application thread that 
         // the operation is complete.
         state->OperationComplete->Set();
      }
      // Return exceptions to the main application thread.
      catch ( Exception^ e ) 
      {
         Console::WriteLine( "Error getting response." );
         state->OperationException = e;
         state->OperationComplete->Set();
      }
   }
};

int main()
{
   AsynchronousFtpUpLoader::Main();
}
using System;
using System.Net;
using System.Threading;

using System.IO;
namespace Examples.System.Net
{
    public class FtpState
    {
        private ManualResetEvent wait;
        private FtpWebRequest request;
        private string fileName;
        private Exception operationException = null;
        string status;

        public FtpState()
        {
            wait = new ManualResetEvent(false);
        }

        public ManualResetEvent OperationComplete
        {
            get {return wait;}
        }

        public FtpWebRequest Request
        {
            get {return request;}
            set {request = value;}
        }

        public string FileName
        {
            get {return fileName;}
            set {fileName = value;}
        }
        public Exception OperationException
        {
            get {return operationException;}
            set {operationException = value;}
        }
        public string StatusDescription
        {
            get {return status;}
            set {status = value;}
        }
    }
    public class AsynchronousFtpUpLoader
    {
        // Command line arguments are two strings:
        // 1. The url that is the name of the file being uploaded to the server.
        // 2. The name of the file on the local machine.
        //
        public static void Main(string[] args)
        {
            // Create a Uri instance with the specified URI string.
            // If the URI is not correctly formed, the Uri constructor
            // will throw an exception.
            ManualResetEvent waitObject;

            Uri target = new Uri (args[0]);
            string fileName = args[1];
            FtpState state = new FtpState();
            FtpWebRequest request = (FtpWebRequest)WebRequest.Create(target);
            request.Method = WebRequestMethods.Ftp.UploadFile;

            // This example uses anonymous logon.
            // The request is anonymous by default; the credential does not have to be specified.
            // The example specifies the credential only to
            // control how actions are logged on the server.

            request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");

            // Store the request in the object that we pass into the
            // asynchronous operations.
            state.Request = request;
            state.FileName = fileName;

            // Get the event to wait on.
            waitObject = state.OperationComplete;

            // Asynchronously get the stream for the file contents.
            request.BeginGetRequestStream(
                new AsyncCallback (EndGetStreamCallback),
                state
            );

            // Block the current thread until all operations are complete.
            waitObject.WaitOne();

            // The operations either completed or threw an exception.
            if (state.OperationException != null)
            {
                throw state.OperationException;
            }
            else
            {
                Console.WriteLine("The operation completed - {0}", state.StatusDescription);
            }
        }
        private static void EndGetStreamCallback(IAsyncResult ar)
        {
            FtpState state = (FtpState) ar.AsyncState;

            Stream requestStream = null;
            // End the asynchronous call to get the request stream.
            try
            {
                requestStream = state.Request.EndGetRequestStream(ar);
                // Copy the file contents to the request stream.
                const int bufferLength = 2048;
                byte[] buffer = new byte[bufferLength];
                int count = 0;
                int readBytes = 0;
                FileStream stream = File.OpenRead(state.FileName);
                do
                {
                    readBytes = stream.Read(buffer, 0, bufferLength);
                    requestStream.Write(buffer, 0, readBytes);
                    count += readBytes;
                }
                while (readBytes != 0);
                Console.WriteLine ("Writing {0} bytes to the stream.", count);
                // IMPORTANT: Close the request stream before sending the request.
                requestStream.Close();
                // Asynchronously get the response to the upload request.
                state.Request.BeginGetResponse(
                    new AsyncCallback (EndGetResponseCallback),
                    state
                );
            }
            // Return exceptions to the main application thread.
            catch (Exception e)
            {
                Console.WriteLine("Could not get the request stream.");
                state.OperationException = e;
                state.OperationComplete.Set();
                return;
            }
        }

        // The EndGetResponseCallback method
        // completes a call to BeginGetResponse.
        private static void EndGetResponseCallback(IAsyncResult ar)
        {
            FtpState state = (FtpState) ar.AsyncState;
            FtpWebResponse response = null;
            try
            {
                response = (FtpWebResponse) state.Request.EndGetResponse(ar);
                response.Close();
                state.StatusDescription = response.StatusDescription;
                // Signal the main application thread that
                // the operation is complete.
                state.OperationComplete.Set();
            }
            // Return exceptions to the main application thread.
            catch (Exception e)
            {
                Console.WriteLine ("Error getting response.");
                state.OperationException = e;
                state.OperationComplete.Set();
            }
        }
    }
}

備註

重要

我們不建議您將類別用於 FtpWebRequest 新的開發。We don't recommend that you use the FtpWebRequest class for new development. 如需的詳細資訊和替代方法 FtpWebRequest ,請參閱 WebRequest 不應 在 GitHub 上使用。For more information and alternatives to FtpWebRequest, see WebRequest shouldn't be used on GitHub.

若要取得的實例 FtpWebRequest ,請使用 Create 方法。To obtain an instance of FtpWebRequest, use the Create method. 您也可以使用 WebClient 類別,從 FTP 伺服器上傳及下載資訊。You can also use the WebClient class to upload and download information from an FTP server. 使用上述任一種方法時,當您指定使用 FTP 配置的網路資源時 (例如, "ftp://contoso.com") 類別可讓您以程式設計 FtpWebRequest 方式與 ftp 伺服器互動。Using either of these approaches, when you specify a network resource that uses the FTP scheme (for example, "ftp://contoso.com") the FtpWebRequest class provides the ability to programmatically interact with FTP servers.

URI 可以是相對或絕對的。The URI may be relative or absolute. 如果 URI 的格式為 "ftp://contoso.com/%2fpath" (% 2f 是一個轉義的 '/' ) ,則 uri 是絕對的,而目前的目錄是 /pathIf the URI is of the form "ftp://contoso.com/%2fpath" (%2f is an escaped '/'), then the URI is absolute, and the current directory is /path. 但是,如果 URI 的格式是,則會 "ftp://contoso.com/path" 先使用) 屬性所設定的使用者名稱和密碼,.NET Framework 登入 FTP 伺服器 (Credentials ,然後將目前的目錄設為 <UserLoginDirectory>/pathIf, however, the URI is of the form "ftp://contoso.com/path", first the .NET Framework logs into the FTP server (using the user name and password set by the Credentials property), then the current directory is set to <UserLoginDirectory>/path.

您必須有伺服器的有效使用者名稱和密碼,或者伺服器必須允許匿名登入。You must have a valid user name and password for the server or the server must allow anonymous logon. 您可以藉由設定屬性來指定用來連接到伺服器的認證,也可以將 Credentials 它們包含在 UserInfo 傳遞給方法的 URI 部分中 CreateYou can specify the credentials used to connect to the server by setting the Credentials property or you can include them in the UserInfo portion of the URI passed to the Create method. 如果您在 UserInfo URI 中包含資訊,則 Credentials 會使用指定的使用者名稱和密碼資訊,將屬性設為新的網路認證。If you include UserInfo information in the URI, the Credentials property is set to a new network credential with the specified user name and password information.

警告

除非 EnableSsl 屬性為 true ,否則所有資料和命令(包括您的使用者名稱和密碼資訊)都會以純文字的形式傳送至伺服器。Unless the EnableSsl property is true, all data and commands, including your user name and password information, are sent to the server in clear text. 監視網路流量的任何人都可以查看您的認證,並使用它們來連線到伺服器。Anyone monitoring network traffic can view your credentials and use them to connect to the server. 如果您要連接到需要認證且支援安全通訊端層 (SSL) 的 FTP 伺服器,您應該將設定 EnableSsltrueIf you are connecting to an FTP server that requires credentials and supports Secure Sockets Layer (SSL), you should set EnableSsl to true.

您必須 WebPermission 存取 FTP 資源,否則會擲回例外狀況 SecurityExceptionYou must have WebPermission to access the FTP resource; otherwise, a SecurityException exception is thrown.

藉由將 Method 屬性設定為結構中所定義的值,以指定要傳送至伺服器的 FTP 命令 WebRequestMethods.FtpSpecify the FTP command to send to the server by setting the Method property to a value defined in the WebRequestMethods.Ftp structure. 若要傳輸文字資料,請將 UseBinary 屬性從預設值 (true) 變更為 falseTo transmit text data, change the UseBinary property from its default value (true) to false. 如需詳細資訊和限制,請參閱 MethodFor details and restrictions, see Method.

使用 FtpWebRequest 物件將檔案上傳到伺服器時,您必須將檔案內容寫入透過呼叫 GetRequestStream 方法或其非同步對應項(和方法)取得的要求資料流程 BeginGetRequestStream EndGetRequestStreamWhen using an FtpWebRequest object to upload a file to a server, you must write the file content to the request stream obtained by calling the GetRequestStream method or its asynchronous counterparts, the BeginGetRequestStream and EndGetRequestStream methods. 在傳送要求之前,您必須先寫入資料流程並關閉資料流程。You must write to the stream and close the stream before sending the request.

要求會藉由呼叫 GetResponse 方法或其非同步對應專案、和方法傳送至 BeginGetResponse 伺服器 EndGetResponseRequests are sent to the server by calling the GetResponse method or its asynchronous counterparts, the BeginGetResponse and EndGetResponse methods. 當要求的作業完成時, FtpWebResponse 會傳回物件。When the requested operation completes, an FtpWebResponse object is returned. 物件會提供作業的 FtpWebResponse 狀態,以及從伺服器下載的任何資料。The FtpWebResponse object provides the status of the operation and any data downloaded from the server.

您可以使用屬性來設定讀取或寫入伺服器的超時值 ReadWriteTimeoutYou can set a time-out value for reading or writing to the server by using the ReadWriteTimeout property. 如果超過超時期間,呼叫方法會擲回, WebExceptionWebExceptionStatus 將設定為 TimeoutIf the time-out period is exceeded, the calling method throws a WebException with WebExceptionStatus set to Timeout.

從 FTP 伺服器下載檔案時,如果命令成功,則會在回應物件的資料流程中提供所要求檔案的內容。When downloading a file from an FTP server, if the command was successful, the contents of the requested file are available in the response object's stream. 您可以藉由呼叫方法來存取此資料流程 GetResponseStreamYou can access this stream by calling the GetResponseStream method. 如需詳細資訊,請參閱FtpWebResponseFor more information, see FtpWebResponse.

如果 Proxy 已設定屬性(不論是直接或在設定檔中),則會透過指定的 proxy 來與 FTP 伺服器進行通訊。If the Proxy property is set, either directly or in a configuration file, communications with the FTP server are made through the specified proxy. 如果指定的 proxy 是 HTTP proxy,則只 DownloadFile 支援、 ListDirectoryListDirectoryDetails 命令。If the specified proxy is an HTTP proxy, only the DownloadFile, ListDirectory, and ListDirectoryDetails commands are supported.

只會快取已下載的二進位內容;亦即,使用命令所收到的內容, DownloadFile 並將 UseBinary 屬性設定為 trueOnly downloaded binary content is cached; that is, content received using the DownloadFile command with the UseBinary property set to true.

FtpWebRequest如果可能的話,多個會重複使用現有的連接。Multiple FtpWebRequests reuse existing connections, if possible.

如需 FTP 通訊協定的詳細資訊,請參閱 RFC 959:檔案傳輸通訊協定For more information about the FTP protocol, see RFC 959: File Transfer Protocol.

屬性

AuthenticationLevel

取得或設定值,指出用於這個要求的驗證和模擬等級。Gets or sets values indicating the level of authentication and impersonation used for this request.

(繼承來源 WebRequest)
CachePolicy

取得或設定這個要求的快取原則。Gets or sets the cache policy for this request.

(繼承來源 WebRequest)
ClientCertificates

取得或設定用來建立與 FTP 伺服器之加密連接的憑證。Gets or sets the certificates used for establishing an encrypted connection to the FTP server.

ConnectionGroupName

取得或設定連接群組的名稱,這個連接群組包含用來傳送目前要求的服務點。Gets or sets the name of the connection group that contains the service point used to send the current request.

ContentLength

取得或設定 FtpWebRequest 類別忽略的值。Gets or sets a value that is ignored by the FtpWebRequest class.

ContentOffset

取得或設定這個要求所下載之檔案的位元組位移。Gets or sets a byte offset into the file being downloaded by this request.

ContentType

永遠擲回 NotSupportedExceptionAlways throws a NotSupportedException.

CreatorInstance
已過時。

在子代類別中覆寫時,取得衍生自 IWebRequestCreate 類別的 Factory 物件,用來建立執行個體化的 WebRequest 以對指定的 URI 提出要求。When overridden in a descendant class, gets the factory object derived from the IWebRequestCreate class used to create the WebRequest instantiated for making the request to the specified URI.

(繼承來源 WebRequest)
Credentials

取得或設定用來與 FTP 伺服器通訊的認證。Gets or sets the credentials used to communicate with the FTP server.

DefaultCachePolicy

為所有 FTP 要求,定義預設的快取原則。Defines the default cache policy for all FTP requests.

EnableSsl

取得或設定 Boolean,指定是否應使用 SSL 連線。Gets or sets a Boolean that specifies that an SSL connection should be used.

Headers

取得空的 WebHeaderCollection 物件。Gets an empty WebHeaderCollection object.

ImpersonationLevel

取得或設定目前要求的模擬等級。Gets or sets the impersonation level for the current request.

(繼承來源 WebRequest)
KeepAlive

取得或設定 Boolean 值,指定在要求完成之後,與 FTP 伺服器的控制連接是否關閉。Gets or sets a Boolean value that specifies whether the control connection to the FTP server is closed after the request completes.

Method

取得或設定要傳送至 FTP 伺服器的命令。Gets or sets the command to send to the FTP server.

PreAuthenticate

永遠擲回 NotSupportedExceptionAlways throws a NotSupportedException.

Proxy

取得或設定用來與 FTP 伺服器通訊的 Proxy。Gets or sets the proxy used to communicate with the FTP server.

ReadWriteTimeout

取得或設定讀取或寫入資料流的逾時。Gets or sets a time-out when reading from or writing to a stream.

RenameTo

取得或設定重新命名檔案的新名稱。Gets or sets the new name of a file being renamed.

RequestUri

取得這個執行個體所要求的 URI。Gets the URI requested by this instance.

ServicePoint

取得用來連接到 FTP 伺服器的 ServicePoint 物件。Gets the ServicePoint object used to connect to the FTP server.

Timeout

取得或設定等待要求的毫秒數。Gets or sets the number of milliseconds to wait for a request.

UseBinary

取得或設定 Boolean 值,指定檔案傳輸的資料型別。Gets or sets a Boolean value that specifies the data type for file transfers.

UseDefaultCredentials

永遠擲回 NotSupportedExceptionAlways throws a NotSupportedException.

UsePassive

取得或設定用戶端應用程式之資料傳輸處理序的行為。Gets or sets the behavior of a client application's data transfer process.

方法

Abort()

結束非同步 FTP 作業。Terminates an asynchronous FTP operation.

BeginGetRequestStream(AsyncCallback, Object)

開始非同步開啟要求的內容資料流,以進行寫入。Begins asynchronously opening a request's content stream for writing.

BeginGetResponse(AsyncCallback, Object)

開始以非同步的方式傳送要求,並且接收來自 FTP 伺服器的回應。Begins sending a request and receiving a response from an FTP server asynchronously.

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(繼承來源 MarshalByRefObject)
EndGetRequestStream(IAsyncResult)

結束由 BeginGetRequestStream(AsyncCallback, Object) 所啟動的暫止非同步作業。Ends a pending asynchronous operation started with BeginGetRequestStream(AsyncCallback, Object).

EndGetResponse(IAsyncResult)

結束由 BeginGetResponse(AsyncCallback, Object) 所啟動的暫止非同步作業。Ends a pending asynchronous operation started with BeginGetResponse(AsyncCallback, Object).

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetLifetimeService()
已過時。

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(繼承來源 MarshalByRefObject)
GetObjectData(SerializationInfo, StreamingContext)

將序列化目標物件所需的資料填入 SerializationInfoPopulates a SerializationInfo with the data needed to serialize the target object.

(繼承來源 WebRequest)
GetRequestStream()

擷取用來上載資料至 FTP 伺服器的資料流。Retrieves the stream used to upload data to an FTP server.

GetRequestStreamAsync()

在子代類別中覆寫時,傳回以非同步作業方式將資料寫入網際網路資源的 StreamWhen overridden in a descendant class, returns a Stream for writing data to the Internet resource as an asynchronous operation.

(繼承來源 WebRequest)
GetResponse()

傳回 FTP 伺服器回應。Returns the FTP server response.

GetResponseAsync()

在子代類別中覆寫時,傳回對網際網路要求的回應,做為非同步作業。When overridden in a descendant class, returns a response to an Internet request as an asynchronous operation.

(繼承來源 WebRequest)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
InitializeLifetimeService()
已過時。

取得存留期服務物件,以控制這個執行個體的存留期原則。Obtains a lifetime service object to control the lifetime policy for this instance.

(繼承來源 MarshalByRefObject)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

(繼承來源 MarshalByRefObject)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

在子代類別中覆寫時,以序列化 WebRequest 所需的資料填入 SerializationInfo 執行個體。When overridden in a descendant class, populates a SerializationInfo instance with the data needed to serialize the WebRequest.

(繼承來源 WebRequest)

適用於

另請參閱