File.Exists is returning false when the file actually exists.
I know it would return false if there’s no read permissions, but I can’t seem to get it right.
More info:
My FTP directory is organized like so:
Root
ImageSite
ImageDirectory
MySite
My .aspx.cs File that's calling File.Exists()
I tried uploading the .aspx.cs file with the same ftp user account as ImageSite & ImageDirectory. Didn’t help.
I also tried replacing forward slashes with back slashes, just to be sure.
Here’s my code – I hard-coded the file path to the complete ftp path of the image directory.
string serverUrl =@"\\fs4-n01\blah\blah\blah\ImageSite.com\web\content\Images\" + product.ImageUrl;
bool exists = File.Exists(serverUrl);
I also thought of impersonation. I am already using one identity impersonation in my web.config and it didn’t seem to let me use both, so I placed this one under the subdirectory where my code file is, under tag. But it didn’t seem to do it. (Either way, the owner of the file is the same as the image directory, as I mentioned.)
I’m using ASP.NET 4.0.
Any ideas would be appreciated.
I called my hosting provider (Rackspace) and was told the way .NET works is you cannot access files beyond the content directory for security reasons. (For ASP classic sites, it does let you, as of now.)