在c# Windows Phone 8中使用FilePart POST MultipartData
本文关键字:FilePart POST MultipartData Windows Phone | 更新日期: 2023-09-27 17:50:05
我有一些问题发布图像到我的WebService
在c#
。
WebService是用JAVA编写的。
public static int myFunction(MultipartFormData data) {
List<FilePart> files = data.getFiles();
//...
}
我不知道如何发送c#
在Windows Phone中的File Part
列表。
谢谢你的帮助
您将拥有web服务的Url,对吗?然后你可以使用
MultipartFormDataContent content = new MultipartFormDataContent();
你的文件应该转换为内存流,应该添加到内容
content.Add(new StreamContent(yourData), "filename", fileName);
HttpResponseMessage response = await client.PostAsync(fileUploadUrl, content);
response.EnsureSuccessStatusCode();
string responseBodyAsText = await response.Content.ReadAsStringAsync();