35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using Fab2ApprovalSystem.DMO;
|
|
using Fab2ApprovalSystem.Misc;
|
|
using System.IO;
|
|
using System.Configuration;
|
|
|
|
namespace Fab2ApprovalSystem.Utilities
|
|
{
|
|
public class FileUtilities : Controller
|
|
{
|
|
public ActionResult DownloadFilesFromServer(string pathToFile)
|
|
{
|
|
//string templatesPath = GlobalVars.CA_BlankFormsLocation;
|
|
//string fullName = Server.MapPath("~" + filePath);
|
|
|
|
byte[] fileBytes = GetFile(pathToFile);
|
|
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, pathToFile);
|
|
}
|
|
|
|
public byte[] GetFile(string s)
|
|
{
|
|
System.IO.FileStream fs = System.IO.File.OpenRead(s);
|
|
byte[] data = new byte[fs.Length];
|
|
int br = fs.Read(data, 0, data.Length);
|
|
if (br != fs.Length)
|
|
throw new System.IO.IOException(s);
|
|
return data;
|
|
}
|
|
}
|
|
}
|