Because I have authorization, I can reach files that in another server via file explorer like this:
When I want to download items from that folder in a web project, I get "false" from file.Exists() method. My code is below. What is wrong?
fileNameToShow = fileNameToShow.Replace(" ", "_");
var fileNameAndPath = "\\\\supplier\\SupplierFiles\\Live\\20\\290B_T.N.E.JPG";
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!");
}
