[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2812
  • Last Modified:

How to get the directory attributes like file.getattributes in VB.net

The way we get to know the file attributes throughvb.net code (file.getAttributes), how to get folder attributes.
This is required to know whether the folder is read only or not.
1 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
AllegisIndiaAuthor Commented:
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

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now