Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How to set permission(Full control) to the folder..

How to set permission(Full control) to the folder..

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dotnetkanna
    wrote on last edited by
    #1

    Hi, For a folder i have to set the permission as full control by programmatically,im using C#.Net 2003,How can i accomplish this one,plz help me.. Rgrds Kanna..

    P 1 Reply Last reply
    0
    • D Dotnetkanna

      Hi, For a folder i have to set the permission as full control by programmatically,im using C#.Net 2003,How can i accomplish this one,plz help me.. Rgrds Kanna..

      P Offline
      P Offline
      Pranav Soral
      wrote on last edited by
      #2

      Try the following. //Add these namespaces to your page. using System.IO; using System.Security.AccessControl; using System.Security.Principal; //Put this code in either Page_Load or any other function string DirectoryName = @"C:\Test"; //Make sure the directory exists. string Account = @"Domain\username"; //Replace it with your Domain Name and User Name. DirectoryInfo dInfo = new DirectoryInfo(DirectoryName); DirectorySecurity dSecurity = dInfo.GetAccessControl(); dSecurity.AddAccessRule(new FileSystemAccessRule(Account, FileSystemRights.FullControl, AccessControlType.Allow)); dInfo.SetAccessControl(dSecurity); Hope it helps! Pranav

      D 1 Reply Last reply
      0
      • P Pranav Soral

        Try the following. //Add these namespaces to your page. using System.IO; using System.Security.AccessControl; using System.Security.Principal; //Put this code in either Page_Load or any other function string DirectoryName = @"C:\Test"; //Make sure the directory exists. string Account = @"Domain\username"; //Replace it with your Domain Name and User Name. DirectoryInfo dInfo = new DirectoryInfo(DirectoryName); DirectorySecurity dSecurity = dInfo.GetAccessControl(); dSecurity.AddAccessRule(new FileSystemAccessRule(Account, FileSystemRights.FullControl, AccessControlType.Allow)); dInfo.SetAccessControl(dSecurity); Hope it helps! Pranav

        D Offline
        D Offline
        Dotnetkanna
        wrote on last edited by
        #3

        Hi, Thanks for your reply..But i couln't get this namespace using System.Security.AccessControl; Is i want to refer any namespaces for this one?im using framework version is 1.1.4322,for this which namespaces i have to refer..plz tell me.. rgrds Kanna..

        P 1 Reply Last reply
        0
        • D Dotnetkanna

          Hi, Thanks for your reply..But i couln't get this namespace using System.Security.AccessControl; Is i want to refer any namespaces for this one?im using framework version is 1.1.4322,for this which namespaces i have to refer..plz tell me.. rgrds Kanna..

          P Offline
          P Offline
          Pranav Soral
          wrote on last edited by
          #4

          This namespace is specific to .Net 2.0 I will try to write code which works for 1.1. Thanks, Pranav

          D 1 Reply Last reply
          0
          • P Pranav Soral

            This namespace is specific to .Net 2.0 I will try to write code which works for 1.1. Thanks, Pranav

            D Offline
            D Offline
            Dotnetkanna
            wrote on last edited by
            #5

            Thanks for your reply,im searching this code for last one weekbut i couldn't get it,if u give means it will be very helpfull to me.. regards Kanna..

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups