0

我正在尝试使用 API 服务将文件上传到网络,但我无法将本地文件传递到InputStream.

我该怎么做?我使用 aFileWebRequest但不起作用。

Dim uri As New Uri("C:/Captura.PNG")
Dim myFileWebRequest As FileWebRequest = WebRequest.Create(uri)
Dim myFileWebResponse As FileWebResponse = myFileWebRequest.GetResponse()
Dim receiveStream As Stream = myFileWebResponse.GetResponseStream()
4

1 回答 1

1

You shouldn't get local file via http.
Use File.Open method:

Dim fs As FileStream = File.Open("C:/Captura.PNG", _
        FileMode.Open, _
        FileAccess.Write, _
        FileShare.None)

Since FileStream is Stream, you'll get your file.

于 2012-11-27T12:32:14.117 回答