public ActionResult ExportHistoricDeviceEnrol()
{
string fileName = ConfigurationManager.AppSettings.Get("CSVExportHistoricDeviceFileName").ToString();
string filePath = System.Web.HttpContext.Current.Server.MapPath("/UploadedFiles/BulkUploadTemplates/HistoricDevicesEnrol/"+ fileName);
byte[] fileBytes = ConvertFiletobyte(filePath);
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
}
public byte[]
ConvertFiletobyte(string
filePath)
{
System.IO.FileStream filesystem = System.IO.File.OpenRead(filePath);
byte[] bypeResult = new byte[filesystem.Length];
Int64 length = filesystem.Read(bypeResult, 0, bypeResult.Length);
if (length != filesystem.Length)
throw new
System.IO.IOException(s);
return bypeResult;
}
No comments:
Post a Comment