开发者

FtpWebRequest + Windows Azure = not working?

Is it possible download data on Windows Azure via FtpWebRequest (ASP.NET/C#)?

I am doing this开发者_Go百科 currently and not sure if my problem is that FtpWebRequest is in general not working as expected, or if I have a different failure..

Has sb. did this before?


If you're talking about Windows Azure Storage, then definitely not. FTP is not supported.

If you're working with Compute roles, you could write something to support this, but it's DIY, a la: http://blog.maartenballiauw.be/post/2010/03/15/Using-FTP-to-access-Windows-Azure-Blob-Storage.aspx


I could solve my problem doing the ftp-request with FTPLib. This means: You can copy/load files to azure or to an external source! :-)


Make this working also with AlexFTPS , you just need to add 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",
                                                 "name@email.com"),
                                                 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);
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜