A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C# program to get attributes of a specified file
Q:

C# program to get attributes of a specified file

0

Given a file, and we have to get and print file’s attribute using C# program.

File.GetAttributes()

This is a method of "File" class, which returns the specified file's attributes.

Syntax:

FileAttributes GetAttributes(path);

Parameter(s):

  1. path - Filename with its location.

Return value:

This method returns object of FileAttributes, File attribute can be following:

  • Archive
  • Compressed
  • Device
  • Hidden
  • ReadOnly, etc
  •  

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program

using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            FileAttributes F = File.GetAttributes("B123.TXT");

            Console.WriteLine("Attributes are :"+F.ToString());
       
        }
    }
}

Output

Attributes are :Hidden, Archive

Note: In above program, we need to remember, when we use "File" class, System.IO namespace must be included in the program.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now