One way is to create an assembly that has an attribute that demands the
fileIOPermissionAccess permission. Inside the assembly, you can create a
method that does the dirty work. The downside with this is that the entire
class has the permissions, if you want to restrict it to just a method, you
can demand the permission thru code. There's a link with an implementation
sample here:
http://msdn2.microsoft.com/en-us/library/system.security.permissions.fileiopermi
ssion.aspx.
Read the pre-requesits VERY carefully. These are strong permissions you are
asking for and there is a very real potential for you, your code, or rogue
code to subvert or compromise the sub-system.

Signature
--
Regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
> Alvin,
>
[quoted text clipped - 11 lines]
>>>
>>> thanks Brian,
Brian Stoop - 10 Mar 2008 14:50 GMT
Alvin,
It is the FileIOPermissionAccess.PathDiscovery permission I want to set.
(I'm trying to get the value of Environment.SpecialFolder.ApplicationData)
In the msdn examples we get::
FileIOPermission f2 = new FileIOPermission(FileIOPermissionAccess.Read,
"C:\\test_r");
f2.AddPathList(FileIOPermissionAccess.Write | FileIOPermissionAccess.Read,
"C:\\example\\out.txt");
But I cannot figure out the call to set PathDiscovery permission as it has
no path?, and there appears to be no signature for it?
thanks, B
> One way is to create an assembly that has an attribute that demands the
> fileIOPermissionAccess permission. Inside the assembly, you can create a
[quoted text clipped - 22 lines]
>>>>
>>>> thanks Brian,
Alvin Bruney [ASP.NET MVP] - 11 Mar 2008 03:14 GMT
Hold on, why can't you simply access the environment variable, the worker
process should have rights to it. For instance, this code on a web page
returns the name of my computer
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(Environment.MachineName);
}
Modify the code to return what you want.

Signature
--
Regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
> Alvin,
>
[quoted text clipped - 40 lines]
>>>>>
>>>>> thanks Brian,
Brian Stoop - 11 Mar 2008 23:11 GMT
I moved call to the page load, but it still did not return the env variable.
Thanks for your suggestion, B
> Hold on, why can't you simply access the environment variable, the worker
> process should have rights to it. For instance, this code on a web page
[quoted text clipped - 50 lines]
>>>>>>
>>>>>> thanks Brian,
Alvin Bruney [ASP.NET MVP] - 12 Mar 2008 00:26 GMT
using System;
using System.Web;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
//this prints out C:\Users\vapor\AppData\Roaming
//to my web page
}
}

Signature
--
Regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
> I moved call to the page load, but it still did not return the env
> variable.
[quoted text clipped - 55 lines]
>>>>>>>
>>>>>>> thanks Brian,
Brian Stoop - 12 Mar 2008 15:04 GMT
Alvin,
Are you running as an Administrator? If so it will work. Try browsing to
your web application as a "Domain User" only, this is what fails for me.
Thanks, B
> using System;
> using System.Web;
[quoted text clipped - 69 lines]
>>>>>>>>
>>>>>>>> thanks Brian,
Alvin Bruney [ASP.NET MVP] - 13 Mar 2008 00:18 GMT
So if that's the case, you can use impersonation to solve the permissions
issue.

Signature
--
Regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
> Alvin,
>
[quoted text clipped - 76 lines]
>>>>>>>>>
>>>>>>>>> thanks Brian,