SORU
2 Mart 2009, PAZARTESİ


Professional (Service için zaman aşımı ayarlayın.()DownloadFile

webClient.DownloadFile() dosyaya erişim varsa bile bu kadar uzun sürmez ki bunun için bir zaman aşımı ayarlayabilirsiniz ben bir dosya indirmek için kullanıyorum?

CEVAP
16 HAZİRAN 2010, ÇARŞAMBA


Benim cevabım here geliyor

Bankası zaman aşımı özelliği olan bir türetilmiş sınıf WebRequest sınıf yapabilirsiniz:

using System;
using System.Net;

public class WebDownload : WebClient
{
    /// <summary>
    /// Time in milliseconds
    /// </summary>
    public int Timeout { get; set; }

    public WebDownload() : this(60000) { }

    public WebDownload(int timeout)
    {
        this.Timeout = timeout;
    }

    protected override WebRequest GetWebRequest(Uri address)
    {
        var request = base.GetWebRequest(address);
        if (request != null)
        {
            request.Timeout = this.Timeout;
        }
        return request;
    }
}

ve sadece temel WebClient sınıfı gibi kullanabilirsiniz.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Ayite Atiwoto (superjiffrey)

    Ayite Atiwot

    29 EYLÜL 2010
  • KarnasCamillo

    KarnasCamill

    24 EKİM 2007
  • Chaîne de TheMoustic

    Chaîne de T

    5 Kasım 2006