System.Net.FileWebRequest Class

Provides a file system implementation of the System.Net.WebRequest class.

See Also: FileWebRequest Members


public class FileWebRequest : WebRequest, System.Runtime.Serialization.ISerializable


The System.Net.FileWebRequest class implements the System.Net.WebRequest abstract base class for Uniform Resource Identifiers (URIs) that use the file:// scheme to request local files.

Do not use the FileWebRequest.#ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext) constructor. Use the WebRequest.Create(string) method to initialize new instances of the System.Net.FileWebRequest class. If the URI scheme is file://, the WebRequest.Create(string) method returns a System.Net.FileWebRequest object.

The FileWebRequest.GetResponse method makes a synchronous request for the file specified in the FileWebRequest.RequestUri property and returns a System.Net.FileWebResponse object that contains the response. You can make an asynchronous request for the file using the FileWebRequest.BeginGetResponse(AsyncCallback, object) and FileWebRequest.EndGetResponse(IAsyncResult) methods.

When you want to write data to a file, the FileWebRequest.GetRequestStream method returns a System.IO.Stream instance to write to. The FileWebRequest.BeginGetRequestStream(AsyncCallback, object) and FileWebRequest.EndGetRequestStream(IAsyncResult) methods provide asynchronous access to the write data stream.

The System.Net.FileWebRequest class relies on the System.IO.File class for error handling and code access security.


Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0,,