WinXP下无法使用framework4.5
我的程序之前是4.5,使用async和await。但是转到目标框架为4.0的时候,运行报错。
代码如下
async public void PicPost()
{
byte[] img = System.IO.File.ReadAllBytes(path);
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://" + Global.ip + ":" + Global.port);
using (var form = new MultipartFormDataContent())
{
try
{
form.Add(new StringContent(Global.email), "email");
form.Add(new StringContent(PicSendercomboBox.Text), "contactName");
form.Add(new StringContent(PicAddresseecomboBox.Text), "tailNo");
form.Add(new StringContent(PicTitletextBox.Text), "title");
ByteArrayContent byteArrayContent = new ByteArrayContent(img);
byteArrayContent.Headers.Add("Content-Type", "application/octet-stream");
form.Add(byteArrayContent, "content", "im.png");
var response = await client.PostAsync("/api/v1/messages/image/", form);
response.EnsureSuccessStatusCode();
string s = response.StatusCode.ToString();
}
catch
{
MessageBox.Show("发送失败");
}
}
}
}
我这种情况,如何修改呢? async和await换成什么呢?
请大神们帮帮我,稍微写点,方便理解,谢谢了。