0

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

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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: 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.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.