10分 |
你直接把 |
10分 |
private void DownloadImages(string localFolder, string remotPath, string fileName)
{ FtpWebRequest reqFTP; string ftpServerIP = ConfigurationManager.AppSettings[“FtpServer”]; try reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(“ftp://” + ftpServerIP + “:” + ftpPort + “/” + remotPath + “/” + fileName)); reqFTP.Method = WebRequestMethods.Ftp.DownloadFile; reqFTP.UseBinary = true; reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword); FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); Stream ftpStream = response.GetResponseStream(); long cl = response.ContentLength; int bufferSize = 2048; int readCount; byte[] buffer = new byte[bufferSize]; readCount = ftpStream.Read(buffer, 0, bufferSize); while (readCount > 0) readCount = ftpStream.Read(buffer, 0, bufferSize); ftpStream.Close(); outputStream.Close(); response.Close(); //ftpServerIP 、ftpUserID 、ftpPassword、ftpPort 这些配置都写在App.config文件里 调用方法示例: DownloadImages(@”d:\temp”, “ccc/ddd”, “test.jpg”); |
里面有一个GotoDirectory()方法,直接调用 |
|
好吧 各位 我自己也弄出来了,刚才debug的时候才弄明白的,解决的方法和你们说的差不多,谢谢啊
|
|
楼主后来怎么解决的?
|