FileWebRequest.Method 属性

定义

获取或设置用于请求的协议方法。Gets or sets the protocol method used for the request. 此属性保留供将来使用。This property is reserved for future use.

public:
 virtual property System::String ^ Method { System::String ^ get(); void set(System::String ^ value); };
public override string Method { get; set; }
member this.Method : string with get, set
Public Overrides Property Method As String

属性值

要在此请求中使用的协议方法。The protocol method to use in this request.

例外

此方法无效。The method is invalid.

- 或 --or-

不支持该方法。The method is not supported.

- 或 --or-

指定了多个方法。Multiple methods were specified.

示例

下面的代码示例设置用于请求的协议方法。The following code example sets the protocol method used for the request. 请参阅 FileWebRequest 类中的完整示例。Refer to the complete example in the FileWebRequest class.

// Create a Uri object.
Uri^ myUrl = gcnew Uri( String::Format( "file://{0}", fileName ) );

// Create a FileWebRequest object.
myFileWebRequest = dynamic_cast<FileWebRequest^>(WebRequest::CreateDefault( myUrl ));

// Set the timeout to the value selected by the user.
myFileWebRequest->Timeout = timeout;

// Set the Method property to POST
myFileWebRequest->Method = "POST";

// Create a Uri object. 
Uri myUrl = new Uri ("file://" + fileName);

// Create a FileWebRequest object.
myFileWebRequest = (FileWebRequest)WebRequest.CreateDefault (myUrl);

// Set the time-out to the value selected by the user.
myFileWebRequest.Timeout = timeout;

// Set the Method property to POST  
myFileWebRequest.Method = "POST";
' Create a Uri object.to access the file requested by the user. 
Dim myUrl As New Uri("file://" + fileName)

' Create a FileWebRequest object.for the requeste file.
myFileWebRequest = CType(WebRequest.CreateDefault(myUrl), FileWebRequest)

' Set the time-out to the value selected by the user.
myFileWebRequest.Timeout = timeout

' Set the Method property to POST  
myFileWebRequest.Method = "POST"

注解

Method 属性当前未由 FileWebRequest 类使用。The Method property is currently not used by the FileWebRequest class.

适用于