Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Grant 'Write' access to 'All Users' for the 'C:\Temp' directory.

Posted on 2008-10-15
3
Medium Priority
?
636 Views
Last Modified: 2013-11-08
I need a way to grant the 'Write' permission to 'All Users' on the 'C:\Temp' directory. This needs to be a purely code solution (not using external scripts like xcalcs). I need the solution in VB .Net. All the solutions I am finding on the web are huge bits of code, and I am sure there must be an easier way. I'm hoping this could be done in a few lines?
0
Comment
Question by:Blowfelt82
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 2000 total points
ID: 22729885
try this



 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dInf As System.IO.DirectoryInfo
        dInf = New System.IO.DirectoryInfo("c:\aa\")
        Me.setAccessRules(dInf)
    End Sub

    Function setAccessRules(ByRef dInf As System.IO.DirectoryInfo) As Boolean
        Try
            Dim addAccess As New System.Security.AccessControl.FileSystemAccessRule("EVERYONE", _
                                 System.Security.AccessControl.FileSystemRights.FullControl, _
                                 System.Security.AccessControl.AccessControlType.Allow)
            Dim dSec As New System.Security.AccessControl.DirectorySecurity()

            dSec.AddAccessRule(addAccess)

            dInf.SetAccessControl(dSec)
            'completed set of access control!
            Return True
        Catch e As Exception
            MsgBox(e.ToString())
            Return False
        End Try
    End Function 'setAccessRules
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question