TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
mounika madhavaram
NA
42
10.7k
In upload docume method I need to use web client class
Sep 18 2018 4:43 AM
how to Use web client class in UploadDocuments(upload file) method in wpf..
( ObservableCollection
Documents) i have selected files.
private void UploadDocuments(ObservableCollection
Documents)
{
HttpRequestMessage message = new HttpRequestMessage();
MultipartFormDataContent content = new MultipartFormDataContent();
content.Add(new StringContent(JsonConvert.SerializeObject(Documents)), "seriliazedContent");
foreach (var item in Documents)
{
FileStream filestream = new FileStream(item.Path, FileMode.Open, FileAccess.Read);
content.Add(new StreamContent(filestream), "file", item.OriginalFileName);
}
message.Method = HttpMethod.Post;
message.Content = content;
message.RequestUri = new Uri(ProHelper.GetProMoveServer() + "api/Utility/uploaddocuments");
var client = HttpClientFactory.Create();
client.SendAsync(message).ContinueWith(task =>
{
var response = task.Result.Content.ReadAsStringAsync();
var json = JsonConvert.DeserializeObject
>(response.Result);
});
}
Can any one suggest....
Reply
Answers (
0
)
How to upload multiple files in wpf using web client class
Application freeze