I have been trying to download an application from our server (...//
install//android//myApp.APK) from my Android Phone but am getting an
htm file instead... myApp.APK. When I tried it on the Website on my
PC, it worked fine. Heres my code. Any help will be appreciated.

public static void DownloadFile(string filename, string sContentType,
System.Web.UI.Page page)
    {
        string path = page.Server.MapPath(filename); //get file object
as FileInfo
        System.IO.FileInfo file = new System.IO.FileInfo(path); //--
if the file exists on the server
        if (file.Exists)
        {
            page.Response.Clear();
            page.Response.AddHeader("Content-Disposition",
"attachment; filename=" + file.Name);
            page.Response.AddHeader("Content-Length",
file.Length.ToString());
            if(sContentType.Length > 0)
                page.Response.ContentType = sContentType;
            else
                page.Response.ContentType = "application/octet-
stream";

            page.Response.WriteFile(file.FullName);
            page.Response.Flush();
            page.Response.End(); //if file does not exist

        }
    }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to