C#网络客户端从FTP下载文件

C#网络客户端从FTP下载文件,c#,ftp,webclient,C#,Ftp,Webclient,我使用以下代码从FTP下载文件 NetworkCredential credential = new NetworkCredential(Properties.Settings.Default.FTPUserName, Properties.Settings.Default.FTPPassword); string inputfilepath = Path.Combine(Properties.Settings.Default.LocalDownloadFolder, file); string

我使用以下代码从FTP下载文件

NetworkCredential credential = new NetworkCredential(Properties.Settings.Default.FTPUserName, Properties.Settings.Default.FTPPassword);
string inputfilepath = Path.Combine(Properties.Settings.Default.LocalDownloadFolder, file);
string ftpfullpath = Properties.Settings.Default.FTPSite + Properties.Settings.Default.FTPFolder + file;

WebClient request1 = new WebClient();
request1.Credentials = credential;
request1.DownloadFile(ftpfullpath, inputfilepath);
前两个变量的值为:

E:\FTPDownloads\CardholderManagementReport_1030_2012-12-11.xls
ftp://abc.com/AKSHAY/CardholderManagementReport_1030_2012-12-11.xls
它将错误显示为:

The remote server returned an error: (550) File unavailable (e.g., file not found, no access).
编辑:
我可以看到文件确实存在,凭据正常,我可以使用FileZilla下载它。FTP服务器返回的错误550表示您尝试访问该文件的用户没有访问该文件的权限

使用其他具有文件访问权限的凭据集,或者更改文件的权限以允许访问。

使其正常工作。


也有解释

问题是什么?你不明白错误信息吗?这个答案对你有帮助吗?请求1.凭证=凭证;此lne设置凭据,并在代码中未提及的行中创建。