1
알려진 원격 파일을 검색하여 브라우저를 통해 방문자에게 반환해야하는 ASP.NET (VB.NET) 응용 프로그램을 만들고 있습니다. 여기에있는 Microsoft의 샘플 (http://support.microsoft.com/?kbid=812406)을 사용하려고하는데 '이 스트림은 검색 작업을 지원하지 않습니다.'라는 오류가 발생합니다. 계속 진행하는 방법을 모르겠습니다.ftp 서버에서 브라우저로 파일 다운로드
여기에 오류 줄이 표시된 코드가 있습니다.
Dim ftpWebReq As Net.FtpWebRequest = CType(Net.WebRequest.Create(path), Net.FtpWebRequest)
ftpWebReq.Method = Net.WebRequestMethods.Ftp.DownloadFile
ftpWebReq.KeepAlive = False
ftpWebReq.UsePassive = False
ftpWebReq.Credentials = New Net.NetworkCredential(System.Web.Configuration.WebConfigurationManager.AppSettings("FtpId"), System.Web.Configuration.WebConfigurationManager.AppSettings("FtpPwd"))
Dim ftpWebResp As Net.FtpWebResponse = CType(ftpWebReq.GetResponse(), Net.FtpWebResponse)
Dim streamer As Stream = ftpWebResp.GetResponseStream()
Dim buffer(10000) As Byte ' Buffer to read 10K bytes in chunk:
Dim length As Integer ' Length of the file:
Dim dataToRead As Long ' Total bytes to read:
dataToRead = streamer.Length ' *** This is the error line ***
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", "attachment; filename=foo.txt")
While dataToRead > 0 ' Read the bytes.
If Response.IsClientConnected Then ' Verify that the client is connected.
length = streamer.Read(buffer, 0, 10000) ' Read the data in buffer
Response.OutputStream.Write(buffer, 0, length) ' Write the data to the current output stream.
Response.Flush() ' Flush the data to the HTML output.
ReDim buffer(10000) ' Clear the buffer
dataToRead = dataToRead - length
Else
dataToRead = -1 'prevent infinite loop if user disconnects
End If
End While
. 고마워요! –