简体   繁体   English

如何在asp.net中生成和下载.imp文件,我应该使用哪种MIME类型?

[英]How to generate and download .imp file in asp.net and what MIME type should I use?

 using System; using System.Text; using System.IO; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace QCSL { public partial class ImpDownload : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //Getting the Id int id = Convert.ToInt32(Request.QueryString["id"].ToString()); // Generating the file string fname = Guid.NewGuid().ToString() + ".IMP"; string TgFile = Server.MapPath("~/downloads/") + fname; BinaryWriter fs = new BinaryWriter(File.Open(TgFile, FileMode.Create)); string header = "<Version>'12001','1'</Version>\\n"; string Body = ""; string BodyH = "<Salinvoice>\\n"; string BodyF = "</Salinvoice>\\n"; //Generating the Content body string custid="*"; string invnum="*"; string invdate="*"; string invamount="*"; string tax="*"; string BodyC = "'"+custid+ "',',',',',',',',','\\n'1', ,'" + invnum + "','" + invdate + "','0', ,'.00','0','1','0','1','5','.00'\\n'90000','1.0000','" + invamount + "','" + invamount + "','1','0','1','5','" + tax + "'\\n"; Body = BodyH + BodyC + BodyF; fs.Write(header + Body); fs.Flush(); fs.Close(); fs.Close(); // downloading the file Response.ContentType = "application/imp"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + fname); Response.TransmitFile(Server.MapPath("~/downloads/" + fname)); Response.End(); //this.ClientScript.RegisterClientScriptBlock(this.GetType(), "Close", "window.close()", true); } } } 

I am using the following code to generate and download .imp file.I do not now what ContentType should I use however code is working fine. 我正在使用以下代码生成和下载.imp文件。我现在不应该使用哪种ContentType,但是代码可以正常工作。 Any help will be appreciated very greatly. 任何帮助将不胜感激。 I have also added source file. 我还添加了源文件。 [![enter image description here][1]][1] [![在此处输入图片描述] [1]] [1]

There is no specific type defined for IMP file, you can use application/octet-stream or application/unknown . 没有为IMP文件定义特定类型,您可以使用application/octet-streamapplication/unknown

if your file is of type Simply Accounting - Data Import then use application/vnd.accpac.simply.imp . 如果文件的类型为Simply Accounting - Data Import则使用application/vnd.accpac.simply.imp You can get all the list of mime type here 您可以在此处获取所有哑剧类型列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM