Response.TransmitFile - Windows Mobile 6

  • Thread starter Thread starter Woodgnome
  • Start date Start date
W

Woodgnome

Hi,

I have use the following code to transmit a file back to the browser that
worked fine on a HTC_TTyN device running windows mobile 5.0. The code
executes in the onclick event of a mobilelist control. Now on a similar
device running window mobile 6.0 the file is not displayed - the link causes
a post back succesfully and the code appears to execute - on the browser a
bar is displayed breifely at the bottom of the window (although ist show 0KB
to the right of the bar.) - seaming to indciate that a file is being
transferred but the file save option (or the file) does not appear.

Does any one have any ideas why this is not working ? I suspect it may be
something that is specific to the HCT_TTyn devcie as we have identifed a
separate issue where the browser capabilities where not being detected
correctly - this was due to the fact that the useragent string was being
prefixed with 'HCT_TTyn ' - to work around this we have defined a new
htctty.browser file and registered it with asp.net which seams to have solved
all the problems we were having - apart from this file transfer issue.

protected bool SendFile(string filePath)
{
string fileName = System.IO.Path.GetFileName(filePath);
if ((fileName != "") && (System.IO.File.Exists(filePath)))
{
try
{
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "application/octet-stream";
Response.AddHeader("content-disposition", @"attachment;
filename=""" + fileName + @"""");
Response.AddHeader("content-length", new
System.IO.FileInfo(filePath).Length.ToString());
Response.TransmitFile(filePath);
Response.Flush();
Response.End();
Response.Close();
return true;
}
catch
{
return false;
}
}
else
return false;
}
 
Back
Top