How to get the directory attributes like file.getattributes in

Posted on 2006-05-08
Last Modified: 2008-09-20
The way we get to know the file attributes code (file.getAttributes), how to get folder attributes.
This is required to know whether the folder is read only or not.
Question by:AllegisIndia
    LVL 14

    Accepted Solution

    You can use the File.GetAttributes() method for directories as well.

            Dim fa As System.IO.FileAttributes
            fa = System.IO.File.GetAttributes("e:\new folder")
            MsgBox(fa.Format(System.Type.GetType("System.IO.FileAttributes"), fa, "G"))


      Nayer Naguib

    Author Comment

    Ya Nayer,
    It works but i need to change little bit.

    If use the above code it will return whether its a file or directory.
    I wanted whether the directory is Read Only or not.

    But modifing your code...
    if System.IO.File.GetAttributes("e:\new folder").readonly=1 then
    msgbox("This directory is readonly.")
    end if

    Thanks once again

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    Join & Write a Comment

    Suggested Solutions

    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    This article will show, step by step, how to integrate R code into a R Sweave document
    This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now