日期:2014-05-17 浏览次数:21407 次
public static bool DisplayFileFromServer(Uri serverUri,string pwd)
{
// The serverUri parameter should start with the ftp:// scheme.
if (serverUri.Scheme != Uri.UriSchemeFtp)
{
return false;
}
WebClient request = new WebClient();
//连接
request.Credentials = new NetworkCredential("forumDB", pwd);
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;
}
static void Main(string[] args)
{
// Download(@"c:/","a.txt");
DisplayFileFromServer(new Uri("ftp://117.79.93.200//13_2_db120617.rar"),"ddddd");
}