Madhav Sharma

Madhav Sharma

  • 880
  • 899
  • 39.9k

Need help, Not able to download the file

Apr 4 2020 4:50 PM
I have tried to download my file from the directory location but unable to download, and it does not give any error. Is this folder permission issue or something code is missing.
 
my complete directory path =  C:\Users\abc\source\repos\SkylandApplication\WebApp\Upload\Documents\5\FranchiseData\Location\1\70054b29-20f1-438e-9c78-521a34107c9d.jpg 
public ActionResult DownloadFranchiseLeftsideImg(CompanyLocationViewModel model)
{
try
{
CompanyLocationViewModel obj = Session["Location"] as CompanyLocationViewModel;
obj.LeftsideImg = model.LeftsideImg;
obj.RightsideImg = null;
obj.InsideImg = null;
obj.OutsideImg = null;
var LeftSideImg = repo_companylayoutlocation.LocationDownloads(obj);
string UploadedPath = System.Configuration.ConfigurationManager.AppSettings["ImagePath"];
string folderName = "FranchiseData/Location/" + obj.LocationId;
String absolutePath = System.Web.Hosting.HostingEnvironment.MapPath(UploadedPath + "\\" + obj.FranchiseId + "\\" + folderName);
string completePath = System.IO.Path.Combine(absolutePath, LeftSideImg);
byte[] fileBytes = System.IO.File.ReadAllBytes(completePath);
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, "LeftSideImg");
//var bytes = System.IO.File.ReadAllBytes(completePath);
//return File(completePath, MimeMapping.GetMimeMapping(completePath), LeftSideImg);
//return File(completePath, "application/force -download", LeftSideImg);
}
catch (Exception ex)
{
throw;
}
 

Answers (2)