Change file attribute in CSharp

Description

The following code shows how to change file attribute.

Example


     /*  ww  w. j av  a2  s.  com*/
using System;
using System.IO;

class Class1
{
  [STAThread]
  static void Main(string[] args)
  {
        File.SetAttributes( "Main.cs", File.GetAttributes("Main.cs") | FileAttributes.ReadOnly );
        File.SetAttributes( "Main.cs", File.GetAttributes("Main.cs") & (~FileAttributes.ReadOnly) );
        
  }
}




















Home »
  C# Tutorial »
    IO »




File Attribute
File Security
Directory Attribute
Directory Recursive
Binary File
Text Field
Buffered IO
Create Copy Delete Move
CSV
Drive
File System Watcher
Isolated Storage
MemoryStream
Serialize
Zip