Is there something built-in to .net to determine if a directory is writeable
by the current user?
I want to write a Windows Powershell script that needs to write to a
directory. I can certainly do something in PSH to get the current user,
then determine if the ACLs will allow writing, but perhaps .net has a
one-liner?
I know I can also just use PSH to try to write to the dir, then retrive the
error value. Still, wondering if there's a prettier solution...
Marco
Vadym Stetsyak - 24 Nov 2006 10:47 GMT
Hello, Marco!
Something tells me that solutions here, as you sad, are:
- write smth ( create a file ) and get exception if there is no access
- analyze ACLs
1-st IMO is faster.
MS> Is there something built-in to .net to determine if a directory is
MS> writeable
MS> by the current user?
MS> I want to write a Windows Powershell script that needs to write to a
MS> directory. I can certainly do something in PSH to get the current
MS> user,
MS> then determine if the ACLs will allow writing, but perhaps .net has
MS> a
MS> one-liner?
MS> I know I can also just use PSH to try to write to the dir, then
MS> retrive the
MS> error value. Still, wondering if there's a prettier solution...
MS> Marco
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Phil Wilson - 27 Nov 2006 21:23 GMT
I suspect you won't find out unless you try to do it. For example, The ACLs
won't matter on Vista if the interactive user is an administrator but
running as a limited user. An attempt to write could cause an elevation
prompt that could then be denied.

Signature
Phil Wilson
[Microsoft MVP Windows Installer]
> Is there something built-in to .net to determine if a directory is
> writeable by the current user?
[quoted text clipped - 8 lines]
>
> Marco