Uwp中的路径太长异常(Uri)

时间:2016-12-15 05:35:50

标签: uwp

目前正尝试通过uri将图片上传到数据库。因为我正在使用HttpClient类。但它显示路径太长的异常。(因为我将图像转换为base64字符串并上传它)。我试图通过WebClient类插入,但遗憾的是Uclp中没有WebClient类。那么我如何通过uri上传图像?

代码

    public async void Upload()
    {

        var url1 = "http://www.example.com/upload.php";
        var values1 = new List<KeyValuePair<String, String>>
        {

             new KeyValuePair<string, string>("Date", x.Date.ToString()),
             new KeyValuePair<string, string>("Bill_Image", x.Bill_Image.ToString()),

         };
             HttpClient client1 = new HttpClient();
             HttpResponseMessage response1 = new HttpResponseMessage();

             try
             {
                response1 = await client1.PostAsync(url1,new FormUrlEncodedContent(values1));

                    if (response1.IsSuccessStatusCode)
                    {
                        var dialog = new MessageDialog("Successfully Added");
                        await dialog.ShowAsync();
                    }
                    else
                    {
                        // problems handling here
                    }
              }
              catch (Exception exc)
              {
                  Debug.WriteLine(exc.ToString());
              }
      }

0 个答案:

没有答案