tags:

views:

115

answers:

2

Hi, I'm running an application from a network share, this application then try to verify if the path "C:\temp" exist and return true or false.

If the code is runned localy, there's no problem. If it's runned from a network share, I get the result false, even if the folder exist localy.

The code is C# on framework 2.0

Thank you

A: 

This has to do with the security policy settings of the .NET framework. By default, code running from the intranet zone (which UNC path are assigned to) are not fully trusted, limiting some of your code to succeed.

You can use the configuration wizards to change these settings if required. Open a Visual Studio command prompt and run "Configwizards.exe".

See also this link for information about CAS configuration.

Lucero
+2  A: 

You would need to run under elevated priviledges to see this. It part of the Code Access Security model.

I would recommend using an application data folder as returned by Environment.GetFolderPath instead of a hard-coded path.

Reed Copsey
I don't normally upvote answers that propose solutions contrary to what the OP wants, but I've seen this problem occur so many times that I think it's important that developers really start using user-specific storage paths.
overslacked
@overslacked: Well, I told him how to get there (run under elevated privs) as well the cause of this problem (CAS)... I just don't think it's the "best" option in this case, hence my suggestion afterwards.
Reed Copsey