开发者

ASP.NET FTP Download

I have a need to push out a file package that includes a driver via my website for download. The only issue is it cannot be transferred in ASCII mode or else it becomes corrupt. I've looked at alternatives for FTP download but would rather not have an application that is created that can be downloaded just to transfer files. I'm looking into the possibility of creating an 开发者_如何学GoASP.NET page that will use FTP for the download process.

I've seen a few examples but I also have a few questions:

  1. How best to protect the login/password information instead of putting it in code? Can that be referenced from web.config?
  2. Any possibility of showing download progress? Is AJAX my only option?
  3. Ability to allow the user to select a download location on their local machine?

EDIT Could I add a MIME type for ZIP and EXE files of application/octet-stream that would force a Binary download of the files?


You can use the WebClient class.

using (WebClient ftpClient = new WebClient())
{
    ftpClient.DownloadFile("ftp://domain.org/file.txt", "file.txt");
}

For authenticated requests

using (WebClient ftpClient = new WebClient())
{
    ftpClient.DownloadFile("ftp://user:pass@domain.org/file.txt", "file.txt");
}


Why FTP? You could create an HTTP Handler to push down the binaries. Here is more information on HTTP Handlers: http://www.15seconds.com/issue/020417.htm

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜