i'd like to send string parameters and file to webserver. i have an error with streamContent This's my code
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;
}
}
}
}
and this is a screenshoot with error: System.ObjectDisposedException https://i.stack.imgur.com/Vt0Df.jpg