File.Exists on the network == wrong?

In my code I do

if (!File.Exists(getSomePath())) { MessageBox.Show("... existing" + " " + getSomePath()); this.Close(); } 

I see that getSomePath() correct, but when I open the application on the network, it says that it does not exist. When I copy the folder to my local drive, it says that it exists.

What's happening?

+4
source share
5 answers

If you use it from a network share, you need users to add the assembly assembly as trusted in .net. The way to do this is to “strongly name” your assembly and have a reliable name on every user computer.

Change The reason for this is security, so a careless user does not receive a virus that starts from a remote (network, etc.) location. This only happens when a user launches an application that lives in a remote location. He can neither access the shared folders nor his own local system from this remote application.

+3
source

You mentioned that it works fine locally, but not when you start it from a network share. Does your application have the appropriate security permissions to access the file system? By default, applications launched from a network share have reduced security permissions.

+1
source

File.Exists most are suspected anyway. But when you open the file, it sounds like a problem with network permissions.

+1
source

Probably SMB caching leads to File.Exists seeing a delayed result.

http://technet.microsoft.com/en-us/library/ff686200(v=WS.10).aspx

+1
source

All Articles