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
  1. Home
  2. General Programming
  3. C#
  4. Changing Folder Permissions C#

Changing Folder Permissions C#

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
5 Posts 3 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.
  • N Offline
    N Offline
    Nicholas Cardi
    wrote on last edited by
    #1

    Does anyone know how to change folder permissions on Windows XP using C#? My problem is that when my application is run under the restricted account under windows XP the folder All Users Application Data has only read access. I want to add write access to that folder the first time the application is run. The application has to be run by an administrator first so I was hoping to do it then. Any Ideas? Forever Developing

    M H 2 Replies Last reply
    0
    • N Nicholas Cardi

      Does anyone know how to change folder permissions on Windows XP using C#? My problem is that when my application is run under the restricted account under windows XP the folder All Users Application Data has only read access. I want to add write access to that folder the first time the application is run. The application has to be run by an administrator first so I was hoping to do it then. Any Ideas? Forever Developing

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      If you want your application to do some admin task in some place you can use WindowsIdentity.Impersonate().Look for sample in MSDN. Mazy No sig. available now.

      1 Reply Last reply
      0
      • N Nicholas Cardi

        Does anyone know how to change folder permissions on Windows XP using C#? My problem is that when my application is run under the restricted account under windows XP the folder All Users Application Data has only read access. I want to add write access to that folder the first time the application is run. The application has to be run by an administrator first so I was hoping to do it then. Any Ideas? Forever Developing

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        There's a couple of articles on this here on code project. A quick search revealed:

        1. Adding File Access Permissions using DirectoryServices[^]
        2. NT Security Classes for .NET[^]

        You could search for additional articles, as well as comments in this forum because it has been discussed several times before. You probably shouldn't modify the ACL of the All Users directory, though. Users should not be able to write files to this directory. If you need the application to save files in a place where other users of the machine can access them, you should consider installing your program into C:\Program Files (where applications are supposed to go anyway) and use a folder within that. By default, most users can write to those directories. All Users is more for things like Start menu shortcuts available to everyone. Occassionally, net admins will put a README file in the Documents folder or something that user can't delete, but this is pretty rare these days with modern networks.

        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

        N 1 Reply Last reply
        0
        • H Heath Stewart

          There's a couple of articles on this here on code project. A quick search revealed:

          1. Adding File Access Permissions using DirectoryServices[^]
          2. NT Security Classes for .NET[^]

          You could search for additional articles, as well as comments in this forum because it has been discussed several times before. You probably shouldn't modify the ACL of the All Users directory, though. Users should not be able to write files to this directory. If you need the application to save files in a place where other users of the machine can access them, you should consider installing your program into C:\Program Files (where applications are supposed to go anyway) and use a folder within that. By default, most users can write to those directories. All Users is more for things like Start menu shortcuts available to everyone. Occassionally, net admins will put a README file in the Documents folder or something that user can't delete, but this is pretty rare these days with modern networks.

          -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

          N Offline
          N Offline
          Nicholas Cardi
          wrote on last edited by
          #4

          I am only saving a .ini file there. The problem with saving the ini file settings to the application root folder is that under windows XP a restricted user has no rights to the program files folder. Thanks for the information it is greatly appriciated. Nick Forever Developing

          H 1 Reply Last reply
          0
          • N Nicholas Cardi

            I am only saving a .ini file there. The problem with saving the ini file settings to the application root folder is that under windows XP a restricted user has no rights to the program files folder. Thanks for the information it is greatly appriciated. Nick Forever Developing

            H Offline
            H Offline
            Heath Stewart
            wrote on last edited by
            #5

            You should consider doing this in the setup of your application or using a separate .ini file for each user.

            -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

            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