Wie generiere und lade ich .imp-Datei in asp.net und welchen MIME-Typ sollte ich verwenden?
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);
}
}
}
ich den folgenden Code verwenden file.I zu generieren und downloaden .imp jetzt nicht, was Content soll ich jedoch Code verwenden, funktioniert prima. Jede Hilfe wird sehr geschätzt werden. Ich habe auch Quelldatei hinzugefügt. [1]