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

x
  • 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.
0
AllegisIndia
Asked:
AllegisIndia
1 Solution
 
nayernaguibCommented:
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
0
 
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
0

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