我想将字符串参数和文件发送到网络服务器。我的 streamContent 出错 这是我的代码
using (var client = new HttpClient())
{
using (var content = new MultipartFormDataContent())
{
content.Add(new StringContent("loginTest"), "login");
content.Add(new StringContent("toto"), "username");
using (fileStream = new FileStream("C:\\test.pdf", FileMode.Open,
FileAccess.Read, FileShare.Read, 4096, useAsync: true))
{
var filestreamContent = new StreamContent(fileStream, 4096);
content.Add(filestreamContent, "documentUpload", "test.pdf");
using (var message = client.PostAsync("http://serverUrl/Create?
method=init", content))
{
var input = message.Result.Content.ReadAsStringAsync().Result;
}
}
}
}
这是一个错误的屏幕截图:System.ObjectDisposedException https://i.imgur.com/IHspYbB.jpg