C# FileInfo Attributes

Description

FileInfo Attributes Gets or sets the attributes for the current file or directory.

Syntax

FileInfo.Attributes has the following syntax.


public FileAttributes Attributes { get; set; }

Example

The following example demonstrates the Attributes property.


// w  w w .  j  a  v  a 2s.c o  m

using System;
using System.IO;
using System.Security.AccessControl;

class FileExample
{
    public static void Main()
    {
        string FileName = @"c:\MyTest.txt";
        FileInfo fInfo = new FileInfo(FileName);
        Console.WriteLine(fInfo.Attributes);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter