第二贴:原贴http://community.csdn.net/Expert/topic/5287/5287523.xml?temp=.4938776
站点下载问题:
已知我的站点IP为211.147.225.XXX FTP user= "myweb " pass= "123456 "
如何下载这个站点下的bin目录下的所有文件
谢谢 急
------解决方案--------------------------------------------------------
http://msdn2.microsoft.com/zh-cn/system.net.webrequestmethods.ftp(VS.80).aspx
------解决方案--------------------------------------------------------
这里面有很详细的例子啊。/// <summary> /// 列出ftp目录所包含的文件信息 /// </summary> /// <param name= "remoteDir "> 远程文件夹 </param> /// <returns> 文件详细信息 </returns> public string ListFiles(string remoteDir) { FtpWebRequest request = GetRequest(remoteDir, false); request.Method = WebRequestMethods.Ftp.ListDirectoryDetails; return GetStreamText(request.GetResponse().GetResponseStream()); } /**//// <summary> /// 下载文件 /// </summary> /// <param name= "localFile "> 本地文件路径 </param> /// <param name= "remoteFile "> 远程文件路径 </param> /// <param name= "useBinary "> 是否采用二进制方式 </param> public void DownloadFile(string localFile, string remoteFile, bool useBinary) { FtpWebRequest request = GetRequest(remoteFile, useBinary); request.Method = WebRequestMethods.Ftp.DownloadFile; WriteStream(request.GetResponse().GetResponseStream(), File.Create(localFile)); }