Export (0) Print
Expand All

FileWebRequest.Timeout Property

Gets or sets the length of time until the request times out.

[Visual Basic]
Overrides Public Property Timeout As Integer
public override int Timeout {get; set;}
public: __property int get_Timeout();
public: __property void set_Timeout(int);
public override function get Timeout() : int;
public override function set Timeout(int);

Property Value

The time, in milliseconds, until the request times out, or the value Timeout.Infinite to indicate that the request does not time out.


Exception Type Condition
ArgumentException Timeout is set to less than 0.


[Visual Basic, C#, C++] The following example sets the Timeout property. Refer to the complete example in the FileWebRequest class.

[Visual Basic] 
' 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

// 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;

// Create a Uri object.
Uri* myUrl = new Uri(String::Format(S"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;

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

FileWebRequest Class | FileWebRequest Members | System.Net Namespace

© 2015 Microsoft