ASP.NET Function to Check user has read access to a file

G

Girish bharadwaj

I would think FileIOPermission might help you. See help for that class and
related Security demands and asserts to see if they help you out.

--
Girish Bharadwaj
http://msmvps.com/gbvb
Hi all,

I need a function which will return read access for the current user as true
or false when a file path is passed to it (either local or UNC share).

My web-config file is using windows authentication and impersonate = true.
The idea is to check that the user has access to each file before displaying
it in a list.

Thanks for any help!
 
R

Raed Sawalha

Hi all,

I need a function which will return read access for the current user as true or false when a file path is passed to it (either local or UNC share).

My web-config file is using windows authentication and impersonate = true. The idea is to check that the user has access to each file before displaying it in a list.

Thanks for any help!
 
R

Raed Sawalha

ya that worked fine i did like this and worked perfectly

FileIOPermission f = new
FileIOPermission(FileIOPermissionAccess.AllAccess,MyFile);


try

{

f.Demand();

return true;



}

catch

{

Exception ex = new Exception();

string s = ex.Message ;

return false

}

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top