ورود

View Full Version : دانلود فایل tif



alireza.tabesh
شنبه 30 فروردین 1393, 15:48 عصر
سلام ، من یک مشکل توی دریافت فایل های tif دارم ، اینکه یک فایل tif چند صفحه ای به یک فایل tif یک صفحه ای تبدیل میشه .
کد :

public JsonResult SaveFile(Guid pkItemId)
{
var message = Db.IVR_Message.Find(pkItemId);
string path = message.MsgFileName;


System.Drawing.Image img;
try
{
img = System.Drawing.Image.FromFile(path);
}
catch
{
throw new Exception();
}


Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment; filename=download-fax-page.tif");
Response.ContentType = "application/tif";
Response.Charset = "UTF-8";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);


img.Save(Response.OutputStream, ImageFormat.Tiff);


Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();


return Json(Response, JsonRequestBehavior.AllowGet);
}

alireza.tabesh
شنبه 30 فروردین 1393, 16:05 عصر
کد رو به این شکل تغییر دادم درست شد. ممنون :

public JsonResult SaveFile(Guid pkItemId)
{
var message = Db.IVR_Message.Find(pkItemId);
string path = message.MsgFileName;
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment; filename=download-fax-page.tif");
Response.ContentType = "application/tif";
Response.Charset = "UTF-8";
Response.BinaryWrite(System.IO.File.ReadAllBytes(p ath));
var file = File(path, "text/octet-stream", "download-fax-all-pages.tif");
return Json(file, JsonRequestBehavior.AllowGet);
}