ftp下载 包501错误,说参数有错或无效上代码
- C# code
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");}
1.我确定 这个跟目录下确实有这个文件
2.用dos和游览器地址都能访问并下载,是我哪写错了?
也欢迎别人能提供ftp下载代码.
------解决方案--------------------------------------------------------
地址毛病