471,599 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,599 software developers and data experts.

can I grant write permissions to a folder for restricted user.

In my application, I want to copy some file from network location to local
machine folder. It works fine for administrator but If I run it with
restricted user (not having permissions to local machine folder) it gives me
Access denied error.
How can I programmatically give permission to the foder for restrcited user.
Nov 17 '05 #1
1 7656
Hello Kiran,
In my application, I want to copy some file from network location to local
machine folder. If I run it with restricted user it gives me Access denied
error.
How can I programmatically give permission to the foder for restrcited
user.


If you are using C# 2.0, you could use the
System.Security.AccessControl.FileSecurity class and its SetAccessRule
method (for example) to modify the Access Control List (ACL) of the folder
you want to write to.

However, if the restricted user is not allowed by the administrator to
change the permissions of the folder, then you are out of luck. Here's an
easy rule of thumb: if you cannot do something interactively (i.e. copy a
file to a folder), then you also cannot write code that would suddenly let
you write to that folder.

So you either need to give more permissions to the restricted user, or copy
your file to another folder.

Hope this helps.

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
ja***@removethis.dystopia.fi
http://www.saunalahti.fi/janij/
Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by frekster | last post: by
6 posts views Thread by Fred W. | last post: by
1 post views Thread by =?Utf-8?B?R2FuZXNoIE11dGh1dmVsdQ==?= | last post: by
2 posts views Thread by XIAOLAOHU | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.