Currently, I'm trying to upload files from a server using web services in the portable library. For each file, I make this :
WebRequest request = WebRequest.Create("http://localhost:49364/" + url);
request.BeginGetResponse((aResult) =>
{
var retour = aResult.AsyncState as WebRequest;
WebResponse reponse = retour.EndGetResponse(aResult);
callback(reponse);
}, request);
On my callback method, I make this :
byte[] bytes;
string currentFileName = fileName;
string categorie = currentFileName.Split('/').ElementAt(0);
string dir = currentFileName.Split('/').ElementAt(1);
using (var reader = new BinaryReader(reponse2.GetResponseStream()))
{
bytes = new byte[reponse2.ContentLength];
reader.Read(bytes, 0, (int)reponse2.ContentLength);
}
fileService.EnsureFolderExists(categorie);
fileService.EnsureFolderExists(fileService.PathCombine(categorie, dir));
fileService.WriteFile(currentFileName, bytes);
I get the whole file as a byte array. But, with winRT, writing the file stops quickly and my local file is not complete. If I try to upload just one file, the writing also stops. But, if I try with Silverlight (I extended MvvmCross to Silverlight), the writing is complete. I have not yet tested for MonoDroid et MonoTouch.
So, my question is: Why the writing stops?