Compact框架中的XML文件下载

时间:2023-02-06 09:31:12

Basically, Here is the scenario.I created mobile optimised ASP.NET(3.5 framework) apllication and I added a link to download xml file on to Motorola GUN which runs on comapct framework 5.0 operation system.

基本上,这是scenario.I创建了移动优化的ASP.NET(3.5框架)应用程序,我添加了一个下载xml文件的链接到Motorola GUN,它运行在comapct框架5.0操作系统上。

File download logic works fine on desktop/laptop but on windows CE device Instead of downloading the file.It is opening xml file in IE browser.

文件下载逻辑在桌面/笔记本电脑上工作正常,但在Windows CE设备上而不是下载文件。它是在IE浏览器中打开xml文件。

I need experties help here :)

我需要专家帮助:)

1 个解决方案

#1


0  

The device is going to handle files that it is designed for.

该设备将处理它专为其设计的文件。

You could try sending your file as an octet stream.

您可以尝试将文件作为八位字节流发送。

Here is something similar I did a while back, but I'm not certain if it works on Mobile devices:

这是我之前做过的类似事情,但我不确定它是否适用于移动设备:

    if (!String.IsNullOrEmpty(nameOnly)) {
      string filename = Server.MapPath(nameOnly);
      if (!String.IsNullOrEmpty(filename)) {
        try {
          Response.Buffer = false;
          Response.Clear(); // clear the buffer
          Response.Cache.SetCacheability(HttpCacheability.NoCache);
          if (-1 < filename.IndexOf(".avi")) {
            Response.ContentType = "video/x-msvideo";
          } else if (-1 < filename.IndexOf(".pdf")) {
            Response.ContentType = "Application/pdf";
          } else if (-1 < filename.IndexOf(".rar")) {
            Response.ContentType = "Application/x-rar-compressed";
          } else {
            Response.ContentType = "Application/octet-stream";
          }
          FileInfo file = new FileInfo(filename);
          Response.AddHeader("Content-Disposition", "attachment; filename=" + nameOnly);
          Response.AddHeader("Content-Length", file.Length.ToString());
          Response.WriteFile(file.FullName);
        } catch (Exception err) {
          outputLine = err.Message;
        } finally {
          Response.Flush();
        }
      } else {
        outputLine = string.Format("Server was unable to locate file \"{0}\".", nameOnly);
      }
    }

#1


0  

The device is going to handle files that it is designed for.

该设备将处理它专为其设计的文件。

You could try sending your file as an octet stream.

您可以尝试将文件作为八位字节流发送。

Here is something similar I did a while back, but I'm not certain if it works on Mobile devices:

这是我之前做过的类似事情,但我不确定它是否适用于移动设备:

    if (!String.IsNullOrEmpty(nameOnly)) {
      string filename = Server.MapPath(nameOnly);
      if (!String.IsNullOrEmpty(filename)) {
        try {
          Response.Buffer = false;
          Response.Clear(); // clear the buffer
          Response.Cache.SetCacheability(HttpCacheability.NoCache);
          if (-1 < filename.IndexOf(".avi")) {
            Response.ContentType = "video/x-msvideo";
          } else if (-1 < filename.IndexOf(".pdf")) {
            Response.ContentType = "Application/pdf";
          } else if (-1 < filename.IndexOf(".rar")) {
            Response.ContentType = "Application/x-rar-compressed";
          } else {
            Response.ContentType = "Application/octet-stream";
          }
          FileInfo file = new FileInfo(filename);
          Response.AddHeader("Content-Disposition", "attachment; filename=" + nameOnly);
          Response.AddHeader("Content-Length", file.Length.ToString());
          Response.WriteFile(file.FullName);
        } catch (Exception err) {
          outputLine = err.Message;
        } finally {
          Response.Flush();
        }
      } else {
        outputLine = string.Format("Server was unable to locate file \"{0}\".", nameOnly);
      }
    }