Solved

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

Posted on 2008-10-15
3
628 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
3 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now