mardi 2 décembre 2014

Send file to iPhone/Android from ASP website

Guys I have website (ASP WebForms) In website user can upload and download files. For computer it working good. But Download not working for mobile(upload working) I have Electric Plum for debug with iPhone - and Emulator was closed in this lines :



//Reading the file stream and writing it to page.
FileStream inStream = File.Open(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
outStream.Flush();
long fileSize = inStream.Length;
long bytesSent = 0;
byte[] buf = new byte[64 * 1024];
int bytesRead = inStream.Read(buf, 0, buf.Length);
while (bytesRead > 0 && context.Response.IsClientConnected)
{
try
{
//For Mobile Version need check if we can send file via Stream
outStream.Write(buf, 0, bytesRead);
outStream.Flush();
bytesSent += bytesRead;
bytesRead = inStream.Read(buf, 0, buf.Length);
}
catch
{
bytesRead = 1;
}


in this line:



outStream.Write(buf, 0, bytesRead);
outStream.Flush();
bytesSent += bytesRead;
bytesRead = inStream.Read(buf, 0, buf.Length);


outStream it System.IO.Stream So i think problem with Stream. So guys if somebody have idea how i can resolve it - please write here.


Thank you!!!




Aucun commentaire:

Enregistrer un commentaire