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:
- How best to protect the login/password information instead of putting it in code? Can that be referenced from web.config?
- Any possibility of showing download progress? Is AJAX my only option?
- 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
精彩评论