Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, October 10, 2011 9:42 PM
Hi,
In a web service, i am checking with FileInfo, whether a local file exists, the problem i have found is that when I run the web service in debug mode, then it returns true, but after publishing the service, it returns false. What Am I missing?
Cheers
All replies (10)
Tuesday, October 11, 2011 1:01 PM âś…Answered | 1 vote
Bingo. A Web service is not going to have access to a mapped drive (I assume H is not a physical drive). You'll need to provide the absolute path (e.g. \myserver\myshare\ and that will only work if you've provided appropriate permissions.
Monday, October 10, 2011 11:00 PM
You may be missing permissions. First, check to see if System.IO.File.Exists returns true. That will rule out permissions as the issue.
Monday, October 10, 2011 11:04 PM
Hi Anthony,
System.IO.File.Exists returns false too
Tuesday, October 11, 2011 7:06 AM
If you're getting the file with a relative path, check the current directory in debug mode, and after publishing.
Tuesday, October 11, 2011 8:05 AM
please tell me what is your file path.Any fool can know. The point is to understand.(Albert Einstein)
Tuesday, October 11, 2011 11:01 AM
path is:
h:\data\tree\cuatro\under cover\2011\06\14\20110614-999-CS_#999Alegria.Madrid.01.wmv
Tuesday, October 11, 2011 2:04 PM
One last thing if you dont mind...my service runs under: ASP.NET v4.0 but i don't seem to be able to add it to the folder security. I have added "network service" which i believe is used by the defaultapppool?
Tuesday, October 11, 2011 7:54 PM | 1 vote
What account does it run as though? That will determine the basis for your permissions. Keep in mind that deny overrides allow. Permissions get complicated.
Monday, September 9, 2013 8:23 PM
Hi,
The File.Exist() API returns "true if the caller has the required permissions and path contains the name of an existing file; otherwise, false", and your web service might not have the permission to this location. I have found similar issue with the network service checking a file in temp.
-Sujith
Friday, May 10, 2019 2:38 AM
BINGO, the appropriate permissions have been granted to the location folder, and it still fails regardless..
Bingo ? really.. Think again.