2011-09-17 69 views
0

是否可以通過FtpWebRequest(ASP.NET/C#)在Windows Azure上下載數據?FtpWebRequest + Windows Azure =不工作?

我目前並不能確定這樣做,如果我的問題是:FtpWebRequest是一般工作不正常,或者如果我有一個不同的失敗..

有某人。之前做過?

回答

0

我能解決我的問題做與FTPLib的FTP請求。 這意味着:您可以將文件複製/加載到天藍色或外部源! :-)

0

使這個工作也與AlexFTPS,你只需要添加StartKeepAlive

try 
    { 
     string fileName = Path.GetFileName(this.UrlString); 
     Uri uri = new Uri(this.UrlString); 

     string descFilePath = Path.Combine(this.DestDir, fileName); 

     using (FTPSClient client = new FTPSClient()) 
     { 
      // Connect to the server, with mandatory SSL/TLS 
      // encryption during authentication and 
      // optional encryption on the data channel 
      // (directory lists, file transfers) 
      client.Connect(uri.Host, 
          new NetworkCredential("anonymous", 
               "[email protected]"), 
               ESSLSupportMode.ClearText 
      ); 
      client.StartKeepAlive(); 
      // Download a file 
      client.GetFile(uri.PathAndQuery, descFilePath); 
      client.StopKeepAlive(); 
      client.Close(); 
     } 

    } 
    catch (Exception ex) 
    { 
     throw new Exception("Failed to download", ex); 
    }