开发者

HttpWebRequest Class Text + File in Vb.net

开发者 https://www.devze.com 2022-12-10 20:35 出处:网络
How to create an POS开发者_开发百科T with the HttpWebRequest Class in VB.net (2008)? I can find exemples with text only but not with text and files. Thanks.You should be able to read the file in a buf

How to create an POS开发者_开发百科T with the HttpWebRequest Class in VB.net (2008)? I can find exemples with text only but not with text and files. Thanks.


You should be able to read the file in a buffer, and upload it to the server. It is not that difficult.

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method  "POST";
Stream fileStream = File.OpenRead("filename");
byte [] buffer = new byte[1024];
Stream reqStream = request.GetRequestStream();

int read = fileStream.Read(buffer, 0, buffer.Length);
while(read > 0)
{
reqStream.Write(buffer,0,read);
read  fileStream.Read(buffer, 0, buffer.Length);
}

reqStream.Close();
fileStream.Close();

// now get the response...

Does that help?

0

精彩评论

暂无评论...
验证码 换一张
取 消