我在将数据从 MemoryStream 复制到请求流时遇到问题。
var Request = (HttpWebRequest.Create(Url) as HttpWebRequest);
Request.Method = "PUT";
Stream RequestStream = Request.GetRequestStream();
// write to MemoryStream
var MemStream = new MemoryStream();
byte[] Test = Encoding.ASCII.GetBytes("test000\r\n");
MemStream.Write(Test, 0, Test.Length);
// test writing correctly
byte[] B = MemStream.ToArray();
System.Windows.Forms.MessageBox.Show(Encoding.ASCII.GetString(B)); // shows data correctly
// copy data to request stream(not working!)
MemStream.CopyTo(RequestStream);
// add new data to request stream(working)
byte[] Test1 = Encoding.ASCII.GetBytes("test111");
RequestStream.Write(Test1, 0, Test1.Length);
仅发送到服务器“test111”。有什么想法吗?