I've a grid that contains file list (that on another server) and download buttons for them on each row. When button clicked, file should be downloaded. When I click it on localhost, file.Exist returns true and I can download the file. However, when I try same button on server (IIS), file.Exist returns false and the file cannot be downloaded. (This server also can reach the file.) My code snippet is below;
var fileNameToShow = "8D.xls";
var fileNameAndPath = "\\\\10.1.101.151\\Files\\Live\\10\\8D.xls"
FileInfo file = new FileInfo(fileNameAndPath);
file.Refresh();
if (file.Exists)
{
// Send the file to the browser
Response.Clear();
Response.AddHeader("Content-Disposition",
"attachment; filename= " + fileNameToShow + "; size=" + file.Length.ToString());
Response.TransmitFile(fileNameAndPath);
Response.Flush();
Response.End();
}
else
{
throw new Exception("File does not exist!");
}
What can I do to solve this?
Edit: File is in 10.1.101.151. IIS is in another server. My local is also another PC.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.