0

コードは次のとおりです。

response.Close()
ftpWebRequest = WebRequest.Create(ftp_location & dr("FILE_LOCATION").ToString.Replace("~", ""))
ftpWebRequest.Credentials = New NetworkCredential(ftp_user, ftp_pw)
ftpWebRequest.Method = WebRequestMethods.Ftp.UploadFile
ftpWebRequest.UseBinary = True


                            ftpSourceRequest = WebRequest.Create(ftp_source & dr("FILE_LOCATION").ToString.Replace("~", ""))
                            ftpSourceRequest.Credentials = New NetworkCredential(ftp_user, ftp_pw)
                            ftpSourceRequest.Method = WebRequestMethods.Ftp.DownloadFile
                            ftpSourceRequest.UseBinary = True
                            Try
                                ftpSourceResponse = ftpSourceRequest.GetResponse()
                                Dim t As System.Net.FtpStatusCode = ftpSourceResponse.StatusCode

                                Dim responseStream As IO.Stream = ftpSourceResponse.GetResponseStream
                                ftpStreamWriter = New StreamWriter(ftpWebRequest.GetRequestStream())
                                ftpStreamWriter.Write(New StreamReader(responseStream).ReadToEnd)
                                dr("STATUS") = "OK"
                                dr.AcceptChanges()
                                ftpStreamWriter.Close()
                                response.Close()
                                ftpSourceResponse.Close()
                            Catch ex4 As Exception
                                response.Close()
                                ftpSourceResponse.Close()
                            End Try

問題は、ソースからファイルを実際にダウンロードしてから、目的地にアップロードすることです。ファイル内の唯一のものは、「System.IO.Streamreader」というテキストです。ここで何が間違っていますか?

4

1 に答える 1

0

私は間違っていると目立つものは何も見ませんでした。

取得している「System.IO.Streamreader」は、次の行の場合に期待される結果になります。

ftpStreamWriter.Write(New StreamReader(responseStream).ReadToEnd)

実際には次のようでした:

ftpStreamWriter.Write(New StreamReader(responseStream))

テストしているバージョンに .ReadToEnd があり、コンパイルされていれば問題ないことを再確認できますか?

それが問題ではないと仮定すると、次の場合はどうなりますか。

dim sToWrite as String = New StreamReader(responseStream).ReadToEnd
debug.write(sToWrite)
ftpStreamWriter.Write(sToWrite)

その文字列を確認すると、少なくともデータを正しく読み取っているかどうかがわかります。

多くの型定義が含まれていないため、型を推測する必要がありましたが、オプション strict をオンにして、気付かなかった型の問題をキャッチするかどうかを確認してください。

于 2010-11-15T21:34:23.347 に答える