I am having problems downloading files possibly due to the file extensions not matching the actual file. What is happening is the File.Exists check is returning false for these even though the named file does exist. Is anybody aware of anything in IIS or even IE which would cause this? I have seen this with .txt, .exe. and .avi files. The .avi works of as long as the file really is an avi and not renamed from something else.
Asked
Active
Viewed 728 times
2 Answers
1
Ok, we have an answer.... I actually had double file extensions on the files that were not working but the option to hide known extensions was turned on (I guess by default). The .avi files looked the same as the others so I guess it was considering .avi to be an "unknown" file type. Whatever!
The answer is on my other post here:
Why is FileInfo showing an extra file extension?
Thanks, James
0
Are you doing this within server-side ASP.NET code? If so, you may need to use Server.MapPath or assign the appropriate permissions to be able to access the file's directory.
Please submit code to show what you're trying to do.

David Andres
- 31,351
- 7
- 46
- 36
-
Please see my other post at: http://stackoverflow.com/questions/1384649/how-to-retrive-and-download-server-files-file-exists-and-url Yes, server side code – James Sep 06 '09 at 05:01
-
What I am doing is building a list of URL's which I pass to an ActiveX download control. But I am getting file does not exist on all my test files except for a couple .avi's – James Sep 06 '09 at 05:05
-
Are all of these files within the same directory? In any case, check your permissions. Make sure the ASPNET user has access to the folders you're trying to retrieve files from. – David Andres Sep 06 '09 at 05:13
-
Yes, All are in the same folder so I would think since the .avi files are working that permissions must be ok. I will check. Thanks – James Sep 06 '09 at 13:41
-
Bear in mind that the Everyone user does not include ASPNET, so you'll need to give that user permissions separately. Once done, you can view Effective Permissions on the "missing" files to see if ASPNET can access it. Also, what OS is the server running against, and does it differ from your local environment? – David Andres Sep 06 '09 at 15:44
-
also...make doubly sure that there's nothing added/removed from the file names that are being passed to File.Exists... – David Andres Sep 06 '09 at 15:49
-
See my new post for what the problem is. http://stackoverflow.com/questions/1386338/why-is-fileinfo-showing-an-extra-file-extension – James Sep 06 '09 at 18:33