Exemple #1
0
        /// <summary>
        /// Get the Length of the Http Download.
        /// </summary>
        /// <param name="httpWebOperation">Web Operation.</param>
        /// <param name="username">Http Login Username.</param>
        /// <param name="password">Http Login Password.</param>
        /// <exception cref="ArgumentNullException">Throws if resourceUri is null.</exception>
        public long GetHttpDownloadLength(IWebOperation httpWebOperation, string username, string password)
        {
            if (httpWebOperation == null) throw new ArgumentNullException("httpWebOperation");

             _httpWebOperation = httpWebOperation;
             _httpWebOperation.WebOperationProgress += OnHttpWebOperationProgress;
             _httpWebOperation.OperationRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);

             SetNetworkCredentials(_httpWebOperation.OperationRequest.Request, username, password);
             SetProxy(_httpWebOperation.OperationRequest.Request);

             return _httpWebOperation.GetDownloadLength();
        }
Exemple #2
0
      /// <summary>
      /// Get the Length of the Http Download.
      /// </summary>
      /// <param name="ftpWebOperation">Web Operation.</param>
      /// <param name="username">Http Login Username.</param>
      /// <param name="password">Http Login Password.</param>
      /// <param name="ftpMode">Ftp Transfer Mode.</param>
      /// <exception cref="ArgumentNullException">Throws if resourceUri is null.</exception>
      public long GetFtpDownloadLength(IWebOperation ftpWebOperation, string username, string password, FtpMode ftpMode)
      {
         if (ftpWebOperation == null) throw new ArgumentNullException("ftpWebOperation", "Argument 'httpWebOperation' cannot be null.");

         ftpWebOperation.WebRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
         ((IFtpWebRequest)ftpWebOperation.WebRequest).SetFtpMode(ftpMode);

         ftpWebOperation.WebRequest.SetNetworkCredentials(username, password);
         return ftpWebOperation.GetDownloadLength();
      }