show file attributes

Joined
Nov 7, 2008
Messages
20
Programming Experience
Beginner
I want to display attributes of any file that is (size , name , hidden or not ,extension) in vb.net application.
Can any one help me in sorting out this problem.:)
 
Have a look at the FileInfo class in help, it can give you that file info.
 
You can do all of this using the FileInfo class:
VB.NET:
Dim fi As New FileInfo("File path here")
'fi.Length is the total file size in bytes
'Dim HiddenBoolean As Boolean = ((fi.Attributes And FileAttributes.Hidden) = FileAttributes.Hidden)
'fi.Extension is the file's extension
Here's a link to the MSDN stuff for the control: FileInfo Members (System.IO)

To display the file size in a unit higher than byte's you'll need to do some simple math on it:
VB.NET:
Select Case fi.Length
  Case Is >= 2^40 'TB or larger
    'Do Math
  Case Is >= 2^30 'GB or larger
    'Do Math
  Case Is >= 2^20 'MB or larger
    'Do Math
  Case Is >= 2^10 'KB or larger
    'Do Math
  Case Else 'Smaller than 1 KB
    'Do math, if any
End Select
Refer here as needed: Bit - Wikipedia, the free encyclopedia
 
Back
Top