[ Team LiB ] Previous Section Next Section

FileWebRequestserializable, marshal by reference

System.Net (system.dll)class

This subclass of WebRequest provides access to resources that use the file URL scheme (such as a file on your local filesystem). Use WebRequest.Create( ) with a file:// URL to create an instance of this class. The WebRequest.Create( ) method returns an instance of this class as a reference of type WebRequest.

You may feel a small sense of confusion regarding this type and the "file:" protocol scheme; if a program needs access to a file on the filesystem, why not simply open a System.IO.FileStream instead of using WebRequest.Create("file:/...")? In terms of straight functionality, the System.IO.FileStream call more closely represents the fact that this resource is coming from disk; however, due to the ubiquity of HTTP servers growing within the enterprise, there are often times when a system wishes to equally represent HTTP URLs and filesystem paths within an arbitrary context. For example, a configuration file might be used to indicate where to retrieve user preferences; by specifying the location as a URL rather than an absolute file location, storage of user preferences is permitted on a centralized server without any additional code. (This allows a kind of "roaming preferences" capability within the system.) Many of the .NET tools also use this approach to identify "files" to act upon via command-line parameters.

public class FileWebRequest : WebRequest {
// Protected Constructors
   protected FileWebRequest(System.Runtime.Serialization.SerializationInfo serializationInfo, 
       System.Runtime.Serialization.StreamingContext streamingContext);
// Public Instance Properties
   public override string ConnectionGroupName{set; get; }        
// overrides WebRequest
   public override long ContentLength{set; get; }     
// overrides WebRequest
   public override string ContentType{set; get; }     
// overrides WebRequest
   public override ICredentials Credentials{set; get; }       
// overrides WebRequest
   public override WebHeaderCollection Headers{get; } 
// overrides WebRequest
   public override string Method{set; get; }          
// overrides WebRequest
   public override bool PreAuthenticate{set; get; }   
// overrides WebRequest
   public override IWebProxy Proxy{set; get; }        
// overrides WebRequest
   public override Uri RequestUri{get; } 
// overrides WebRequest
   public override int Timeout{set; get; }            
// overrides WebRequest
// Public Instance Methods
   public override IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state)
// overrides WebRequest
   public override IAsyncResult BeginGetResponse(AsyncCallback callback, object state)
// overrides WebRequest
   public override Stream EndGetRequestStream(IAsyncResult asyncResult)
// overrides WebRequest
   public override WebResponse EndGetResponse(IAsyncResult asyncResult)
// overrides WebRequest
   public override Stream GetRequestStream( );         
// overrides WebRequest
   public override WebResponse GetResponse( );         
// overrides WebRequest
}

Hierarchy

System.Object System.MarshalByRefObject WebRequest(System.Runtime.Serialization.ISerializable) FileWebRequest

    [ Team LiB ] Previous Section Next Section