Thread: Read only attribute

  1. #1
    Registered User
    Join Date
    Dec 2004

    Read only attribute

    How do you programatically remove the "read-only" attribute from a file in a certain directory. I know in VB - I used a shell command in VB - but I suppose there is a more elegant way in C#.


  2. #2
    Registered User
    Join Date
    Mar 2005
    Mountaintop, Pa
    using System;
    using System.IO;
    using System.Text;
    class FileAttributesExample 
        public static void Main() 
               // Remove read only attribute
                string filepath = @"c:\temp\Readonly.txt";
                File.SetAttributes(filepath, FileAttributes.Archive);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Read() problems
    By yay4rei in forum C Programming
    Replies: 2
    Last Post: 07-21-2005, 10:47 AM
  2. How can I know the actual bytes read in a file read
    By pliang in forum C++ Programming
    Replies: 1
    Last Post: 06-08-2005, 04:23 PM
  3. What Would You Use To Read User Input?
    By djwicks in forum C Programming
    Replies: 11
    Last Post: 04-05-2005, 03:32 PM
  4. Read Array pro!!Plz help!!
    By Supra in forum C Programming
    Replies: 2
    Last Post: 03-04-2002, 03:49 PM
  5. Help! Can't read decimal number
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 09-07-2001, 02:09 AM