Read only attribute

This is a discussion on Read only attribute within the C# Programming forums, part of the General Programming Boards category; How do you programatically remove the "read-only" attribute from a file in a certain directory. I know in VB - ...

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    38

    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#.


    Regards

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Code:
    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, 11: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, 05:23 PM
  3. What Would You Use To Read User Input?
    By djwicks in forum C Programming
    Replies: 11
    Last Post: 04-05-2005, 04: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, 03:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21