This is my actionlink on the index view.
@Html.ActionLink("Download File", "Download", new { fileName = Model.OriginalRecordRelativeFilePath })
public FileResult Download(string fileName)
{
try
{
var fs = System.IO.File.OpenRead(Server.MapPath(ConfigurationHelper.IntegrationInterfaceFolderPath + fileName));
// ConfigurationHelper.IntegrationFolderPath is a path for C:\Data\IntergrationInterface\
return File(fs, "application/octet-stream", fileName);
}
catch
{
throw new HttpException(404, "Couldn't find " + fileName);
}
}
I try to download the file from C:\Data\IntergrationInterface\fileName. But it cannot find the path of C:\Data\IntergrationInterface\fileName and throw exception (Couldnt find fileName). May i know is there any ways to download the file from local c while running localhost web service on the same computer? Thank you.
string path = ConfigurationHelper.IntegrationInterfaceFolderPath + fileName; path = Server.MapPath(path); var fs = System.IO.File.OpenRead(path);. Inspect the variables on each step.