FtpWebRequest.Timeout プロパティ
アセンブリ: System (system.dll 内)

Dim instance As FtpWebRequest Dim value As Integer value = instance.Timeout instance.Timeout = value
要求がタイムアウトになるまでのミリ秒単位の待機期間を格納している Int32 値。既定値は Infinite です。


無期限の値を指定するには、Timeout プロパティを Infinite (-1) に設定します。これは既定値です。
Timeout は、GetResponse メソッドで行った同期要求が応答を待機し、GetRequestStream メソッドがストリームを待機する時間を表すミリ秒数です。リソースがタイムアウト時間内に応答しない場合、要求は WebException をスローし、Status プロパティを Timeout に設定します。
GetRequestStream、BeginGetRequestStream、GetResponse、または BeginGetResponse の各メソッドを呼び出した後に Timeout を変更すると、InvalidOperationException 例外が発生します。
ドメイン ネーム システム (DNS: Domain Name System) クエリが値を返すか、タイムアウトするまでに、最大で 15 秒かかることがあります。解決する必要があるホスト名が要求に含まれている場合、Timeout を 15 秒未満の値に設定していても、要求のタイムアウトを示す WebException がスローされるまでに 15 秒以上かかることがあります。

public static bool UploadUniqueFileOnServer (Uri serverUri, string fileName) { // The URI described by serverUri should use the ftp:// scheme. // It contains the name of the directory on the server. // Example: ftp://contoso.com. // // The fileName parameter identifies the file containing the data to be uploaded. if (serverUri.Scheme != Uri.UriSchemeFtp) { return false; } // Get the object used to communicate with the server. FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri); request.Method = WebRequestMethods.Ftp.UploadFileWithUniqueName; // Set a time limit for the operation to complete. request.Timeout = 600000; // Copy the file contents to the request stream. const int bufferLength = 2048; byte[] buffer = new byte[bufferLength]; int count = 0; int readBytes = 0; FileStream stream = File.OpenRead(fileName); Stream requestStream = request.GetRequestStream(); do { readBytes = stream.Read(buffer, 0, bufferLength); requestStream.Write(buffer, 0, bufferLength); count += readBytes; } while (readBytes != 0); Console.WriteLine ("Writing {0} bytes to the stream.", count); // IMPORTANT: Close the request stream before sending the request. requestStream.Close(); FtpWebResponse response = (FtpWebResponse) request.GetResponse(); Console.WriteLine("Upload status: {0}, {1}",response.StatusCode, response.StatusDescription); Console.WriteLine ("File name: {0}", response.ResponseUri); response.Close(); return true; }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からFtpWebRequest.Timeout プロパティを検索する場合は、下記のリンクをクリックしてください。

- FtpWebRequest.Timeout プロパティのページへのリンク