[Serializable] |
file://
scheme to request local files. Do not use the FileWebRequest.#ctor constructor. Use the WebRequest.Create method to initialize new instances of the FileWebRequest class. If the URI scheme is
file://
, the WebRequest.Create method returns a FileWebRequest instance.
The FileWebRequest.GetResponse method makes a synchronous request for the file specified in the FileWebRequest.RequestUri property and returns a FileWebResponse instance containing the response. You can make an asynchronous request for the file using the FileWebRequest.BeginGetResponse and FileWebRequest.EndGetResponse methods.
When you want to write data to a file, the FileWebRequest.GetRequestStream method returns a Stream instance to write to. The FileWebRequest.BeginGetRequestStream and FileWebRequest.EndGetRequestStream methods provide asynchronous access to the write data stream.
The FileWebRequest class relies on the File class for error handling and code access security.
ConnectionGroupName | Read-write Overridden: Gets or sets the name of the connection group for the request. This property is reserved for future use. |
ContentLength | Read-write Overridden: Gets or sets the content length of the data being sent. |
ContentType | Read-write Overridden: Gets or sets the content type of the data being sent. This property is reserved for future use. |
Credentials | Read-write Overridden: Gets or sets the credentials associated with this request. This property is reserved for future use. |
Headers | Read-only Overridden: Gets a collection of the name/value pairs associated with the request. This property is reserved for future use. |
Method | Read-write Overridden: Gets or sets the protocol method used for the request. This property is reserved for future use. |
PreAuthenticate | Read-write Overridden: Gets or sets a value indicating whether to preauthenticate a request. This property is reserved for future use. |
Proxy | Read-write Overridden: Gets or sets the network proxy to use for this request. This property is reserved for future use. |
RequestUri | Read-only Overridden: Gets the URI of the request. |
Timeout | Read-write Overridden: Gets or sets the length of time until the request times out. |
Abort (inherited from System.Net.WebRequest) |
See base class member description: System.Net.WebRequest.Abort Cancels an asynchronous request to an Internet resource. |
BeginGetRequestStream | Overridden: Begins an asynchronous request for a Stream instance to use to write data. |
BeginGetResponse | Overridden: Begins an asynchronous request for a file system resource. |
CreateObjRef (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.CreateObjRef Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. |
EndGetRequestStream | Overridden: Ends an asynchronous request for a Stream instance that the application uses to write data. |
EndGetResponse | Overridden: Ends an asynchronous request for a file system resource. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetLifetimeService (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.GetLifetimeService Retrieves the current lifetime service object that controls the lifetime policy for this instance. |
GetRequestStream | Overridden: Returns a Stream instance for writing data to the file system resource. |
GetResponse | Overridden: Returns a response to a file system request. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
InitializeLifetimeService (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.InitializeLifetimeService Obtains a lifetime service object to control the lifetime policy for this instance. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
ctor #1 | Initializes a new instance of the FileWebRequest class from the specified instances of the SerializationInfo and StreamingContext classes. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
protected FileWebRequest( |
serializationInfo
streamingContext
public override string ConnectionGroupName {get; set;}
|
public override long ContentLength {get; set;}
|
Exception Type | Condition |
---|---|
ArgumentException | FileWebRequest.ContentLength is less than 0. |
public override string ContentType {get; set;}
|
public override ICredentials Credentials {get; set;}
|
public override WebHeaderCollection Headers {get;}
|
public override string Method {get; set;}
|
public override bool PreAuthenticate {get; set;}
|
public override IWebProxy Proxy {get; set;}
|
public override Uri RequestUri {get;}
|
public override int Timeout {get; set;}
|
Exception Type | Condition |
---|---|
ArgumentException | FileWebRequest.Timeout is set to less than 0. |
public virtual void Abort(); |
Exception Type | Condition |
---|---|
NotSupportedException | Any attempt is made to access the method, when the method is not overridden in a descendant class. |
public override IAsyncResult BeginGetRequestStream( |
callback
state
Exception Type | Condition |
---|---|
ProtocolViolationException | The FileWebRequest.Method property is
GET
and the application writes to the stream. |
InvalidOperationException | The stream is being used by a previous call to FileWebRequest.BeginGetRequestStream |
ApplicationException | No write stream is available. |
public override IAsyncResult BeginGetResponse( |
callback
state
Exception Type | Condition |
---|---|
InvalidOperationException | The stream is already in use by a previous call to FileWebRequest.BeginGetResponse. |
requestedType
Exception Type | Condition |
---|---|
RemotingException | This instance is not a valid remoting object. |
public override Stream EndGetRequestStream( |
asyncResult
Exception Type | Condition |
---|---|
ArgumentNullException | asyncResult is null. |
public override WebResponse EndGetResponse( |
asyncResult
Exception Type | Condition |
---|---|
ArgumentNullException | asyncResult is null. |
~FileWebRequest(); |
public virtual int GetHashCode(); |
public object GetLifetimeService(); |
public override Stream GetRequestStream(); |
Exception Type | Condition |
---|---|
WebException | The request times out. |
The FileWebRequest.GetRequestStream method provides synchronous access to the Stream. For asynchronous access, use the FileWebRequest.BeginGetRequestStream and FileWebRequest.EndGetRequestStream methods.
public override WebResponse GetResponse(); |
Exception Type | Condition |
---|---|
WebException | The request timed out. |
The FileWebRequest.GetResponse method provides synchronous access to the WebResponse. For asynchronous access, use the FileWebRequest.BeginGetResponse and FileWebRequest.EndGetResponse methods.
public Type GetType(); |
public virtual object InitializeLifetimeService(); |
public class MyClass : MarshalByRefObject { public override Object InitializeLifetimeService() { ILease lease = (ILease)base.InitializeLifetimeService(); if (lease.CurrentState == LeaseState.Initial) { lease.InitialLeaseTime = TimeSpan.FromMinutes(1); lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); lease.RenewOnCallTime = TimeSpan.FromSeconds(2); } return lease; } }
protected object MemberwiseClone(); |
public virtual string ToString(); |