Create a sub-directory with read permission attributes.

Posted on 2006-05-04
Last Modified: 2008-01-09
I have created a sub-directory, but it seems to have the read-only attribute set.  I have looked and looked and can't find a way to create the directory and set the read-only attribute to false.  

I go in manually and unclick the read-only attribute, only to have it reset automatically somehow... very confusing... can someone enlighten me as to why it keeps getting reset?  (OS is Windows XP)

Thanks in advance.
Question by:rmmarsh
    LVL 35

    Assisted Solution

    Check the parent folder and see if it is set to have permissions propogate to child objects.
    LVL 11

    Accepted Solution

    Suppose you have a folder "New Folder" in the root directory of drive C, with the read-only attribute set,

      string directory = @"C:\New Folder";

    You can remove with this:

      System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(directory);
      directoryInfo.Attributes = directoryInfo.Attributes & ~System.IO.FileAttributes.ReadOnly;

    or this:

      System.IO.File.SetAttributes(directory, System.IO.File.GetAttributes(directory) & ~System.IO.FileAttributes.ReadOnly);

    Author Comment

    Doesn't work on an XP system... no matter what I do, the Read-Only attribute remains set.  I go to the parent directory, remove the RO attribute, click on "all sub-folders" and click on Apply.  When I go back to the Directory, the RO bit is set... no way to remove it.

    I ran into this once before, but for the life of me, I don't remember what I did to remove the RO attribute permanently.
    LVL 35

    Expert Comment

    Is the archive box checked? inside advanced properties?

    Author Comment


    Author Comment

    Now I remember... in XP you can not do a backup to any directory in the c:\program files directory.

    Thanks guys for your help anyway...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 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