服务器提交了协议冲突
下面的代码示例演示如何使用 WebClient 类从 FTP 服务器下载文件。
C# 复制代码public static bool DisplayFileFromServer(Uri serverUri)
{
// The serverUri parameter should start with the ftp:// scheme.
if (serverUri.Scheme != Uri.UriSchemeFtp)
{
return false;
}
// Get the object used to communicate with the server.
WebClient request = new WebClient();
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");
try
{
byte [] newFileData = request.DownloadData (serverUri.ToString());
string fileString = System.Text.Encoding.UTF8.GetString(newFileData);
Console.WriteLine(fileString);
}
catch (WebException e)
{
Console.WriteLine(e.ToString());
}
return true;
}
服务器提交了协议冲突
请问为什么会提示这个错误?
应该怎样利用WebClient从FTP服务器上下载文件呢?
问题点数:50、回复次数:0Top




