Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Directory.Exists() strange behavior

Tags:

c#

.net

iis

wcf

I have an IIS-hosted WCF service and I am trying to use Directory.Exists() method. If nonexistent network location is passed, this method hangs. I've googled for it and found that it's "kind of ok" due to Directory.Exists() inner implementation. But I wrote a simple console application which does the same and Directory.Exists() never hangs, always returns 'false'. I run the application under my (admin) account and IIS pool is running under 'Network Service'.
Do you have any ideas why? What is the difference between doing the same inside a service or a console application?

like image 376
Qué Padre Avatar asked Jan 24 '14 06:01

Qué Padre


1 Answers

This might be caused due to user authorization control stuff that is present in Windows (remember when you try to access a folder that you dont have access in Windows? It kind of waits a long time to answer "You can't access,..." or something like that).

Which is the user you are running the application? Your user id (as per what you said you can access that folder running the console application) is able to see that folder.

So, try to run the application as your own user id.

Furthermore, check this link: https://stackoverflow.com/a/21385162/1378854

like image 57
Lauro Wolff Valente Sobrinho Avatar answered Oct 24 '22 19:10

Lauro Wolff Valente Sobrinho