System.Net.FileWebResponse Class

Assembly: System.dll
Namespace: System.Net
Summary
Provides a file system implementation of the WebResponse class.
C# Syntax:
[Serializable]
public class FileWebResponse : WebResponse
Remarks
The FileWebResponse class implements the WebResponseabstract base class to return file system resources for the FileWebRequest class.

Client applications do not create FileWebResponse instances directly; instead, they are created by calling the FileWebRequest.GetResponse method on a FileWebRequest instance.

The FileWebResponse.GetResponseStream method returns a Stream instance that provides read-only access to a file system resource.

The FileWebResponse class relies on the File class for error handling and code access security.

See also:
System.Net Namespace

System.Net.FileWebResponse Member List:

Public Properties
ContentLength Read-only

Overridden:
Gets the length of the content in the file system resource.
ContentType Read-only

Overridden:
Gets the content type of the file system resource.
Headers Read-only

Overridden:
Gets a collection of header name/value pairs associated with the response.
ResponseUri Read-only

Overridden:
Gets the URI of the file system resource that provided the response.
Public Methods
Close Overridden:
Closes the response stream.
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.
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.
GetResponseStream Overridden:
Returns the data stream from the file system resource.
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.
Protected Constructors
ctor #1 Initializes a new instance of the FileWebResponse class from the specified instances of the SerializationInfo and StreamingContext classes.
Protected Methods
Dispose Releases the unmanaged resources used by the FileWebResponse and optionally releases the managed resources.
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:


System.Net.FileWebResponse Member Details

ctor #1
Summary
Initializes a new instance of the FileWebResponse class from the specified instances of the SerializationInfo and StreamingContext classes.
C# Syntax:
protected FileWebResponse(
   SerializationInfo serializationInfo,
   StreamingContext streamingContext
);
Parameters:

serializationInfo

A SerializationInfo instance that contains the information required to serialize the new FileWebResponse instance.

streamingContext

An instance of the StreamingContext class that contains the source of the serialized stream associated with the new FileWebResponse instance.

Remarks
This constructor implements the ISerializable interface for the FileWebResponse class.
See also:
MSDN: serialization

Return to top


Overridden Property: ContentLength (read-only)
Summary
Gets the length of the content in the file system resource.
C# Syntax:
public override long ContentLength {get;}
Remarks
The FileWebResponse.ContentLength property contains the length, in bytes, of the file system resource.

Return to top


Overridden Property: ContentType (read-only)
Summary
Gets the content type of the file system resource.
C# Syntax:
public override string ContentType {get;}
Remarks
The FileWebResponse.ContentType property contains the content type of the file system resource. The value of FileWebResponse.ContentType is always "binary/octet-stream".

Return to top


Overridden Property: Headers (read-only)
Summary
Gets a collection of header name/value pairs associated with the response.
C# Syntax:
public override WebHeaderCollection Headers {get;}
Remarks
The FileWebResponse.Headers property contains two name/value pairs, one for content length and one for content type, both of which are also exposed as properties, FileWebResponse.ContentLength and FileWebResponse.ContentType.

Return to top


Overridden Property: ResponseUri (read-only)
Summary
Gets the URI of the file system resource that provided the response.
C# Syntax:
public override Uri ResponseUri {get;}
Remarks
The FileWebResponse.ResponseUri property contains the URI of the file system resource that provided the response. This is always the file system resource that was requested.

Return to top


Overridden Method: Close()
Summary
Closes the response stream.
C# Syntax:
public override void Close();
Remarks
The FileWebResponse.Close method cleans up the resources used by a FileWebResponse and closes the response stream by calling the Stream.Close method.

Note The response stream must be closed to avoid running out of system resources. You can closes the response stream by calling either Stream.Close or FileWebResponse.Close

Return to top


Method: CreateObjRef(
   Type requestedType
)
Inherited
See base class member description: System.MarshalByRefObject.CreateObjRef

Summary
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
C# Syntax:
public virtual ObjRef CreateObjRef(
   Type requestedType
);
Parameters:

requestedType

The Type of the object that the new ObjRef will reference.

Return Value:
Information required to generate a proxy.
Exceptions
Exception Type Condition
RemotingException This instance is not a valid remoting object.

Return to top


Method: Dispose(
   bool disposing
)
Summary
Releases the unmanaged resources used by the FileWebResponse and optionally releases the managed resources.
C# Syntax:
protected virtual void Dispose(
   bool disposing
);
Parameters:

disposing

true to release both managed and unmanaged resources; false to release only unmanaged resources.

Remarks
This method is called by the public Dispose() method and the Object.Finalize method.Dispose() invokes the protected Dispose(Boolean) method with the disposing parameter set to true. Object.Finalize invokes Dispose with disposing set to false.

When the disposing parameter is true, this method releases all resources held by any managed objects that this FileWebResponse references. This method invokes the Dispose() method of each referenced object.



Notes to inheritors: Dispose can be called multiple times by other objects. When overriding Dispose(Boolean), be careful not to reference objects that have been previously disposed of in an earlier call to Dispose. For more information about how to implement Dispose(Boolean), see the conceptual topic at MSDN: implementingdisposemethod.

For more information about Dispose and Object.Finalize, see the conceptual topic at MSDN: cleaningupunmanagedresources and the conceptual topic at MSDN: overridingfinalizemethod.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~FileWebResponse();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetLifetimeService()
Inherited
See base class member description: System.MarshalByRefObject.GetLifetimeService

Summary
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
C# Syntax:
public object GetLifetimeService();
Return Value:
An object of type ILease used to control the lifetime policy for this instance.
Remarks
For more information about lifetime services, see the LifetimeServices class.

Return to top


Overridden Method: GetResponseStream()
Summary
Returns the data stream from the file system resource.
C# Syntax:
public override Stream GetResponseStream();
Return Value:
A Stream for reading data from the file system resource.
Remarks
The FileWebResponse.GetResponseStream method returns the data stream from the file system resource.

Note The response stream must be closed to avoid running out of system resources. The response stream can be closed by calling Stream.Close or FileWebResponse.Close

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: InitializeLifetimeService()
Inherited
See base class member description: System.MarshalByRefObject.InitializeLifetimeService

Summary
Obtains a lifetime service object to control the lifetime policy for this instance.
C# Syntax:
public virtual object InitializeLifetimeService();
Return Value:
An object of type ILease used to control the lifetime policy for this instance. This is the current lifetime service object for this instance if one exists; otherwise, a new lifetime service object initialized to the value of the LifetimeServices.LeaseManagerPollTime property.
Remarks
For more information about lifetime services, see the LifetimeServices class.
Example
The following code example demonstrates creating a lease.
 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;
   }
 }

    

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.