I am trying to get attributes of File or directory using vb.net 2005. I am using GetFileAttributesEx. But some how it is not giving me proper info.
can some one help me with getting file information.
Regards,
Narendra Shetty.
File AttributesHow can I get attributes of a file
Page 1 of 1
5 Replies - 23765 Views - Last Post: 29 July 2007 - 09:52 PM
Replies To: File Attributes
#2
Re: File Attributes
Posted 19 June 2007 - 11:43 AM
Can you show how you're using it?
#3
Re: File Attributes
Posted 19 June 2007 - 11:45 AM
Take a look at System.IO.FileInfo and System.IO.DirectoryInfo
For example, to get the size of a file you'd do something like this:
To get the creation time of a directory:
Hope that helps
Cheers
For example, to get the size of a file you'd do something like this:
Dim fileSize as Long = New System.IO.FileInfo("C:\path\to\file.txt").Lenght
To get the creation time of a directory:
Dim creationTime as Date = New System.IO.DirectoryInfo("C:\path\to\dir").CreationTime
Hope that helps
Cheers
This post has been edited by alsaan: 19 June 2007 - 11:48 AM
#4
Re: File Attributes
Posted 19 June 2007 - 11:24 PM
I am using something like this
Dim ret As Long, i As Integer
Dim w As WIN32_FILE_ATTRIBUTE_DATA
ret = GetFileAttributesEx("c:\", 0, w)
here I am confused with second parameter to getFileAttributesEx function.
Also I need to know how can I see the attributes values.
I basically want to check if the file is compressed or not.
Regards,
Narendra Shetty.
Dim ret As Long, i As Integer
Dim w As WIN32_FILE_ATTRIBUTE_DATA
ret = GetFileAttributesEx("c:\", 0, w)
here I am confused with second parameter to getFileAttributesEx function.
Also I need to know how can I see the attributes values.
I basically want to check if the file is compressed or not.
Regards,
Narendra Shetty.
#5
Re: File Attributes
Posted 20 June 2007 - 02:19 PM
Function IsCompressed(ByVal filePath As String) As Boolean Dim attrib As System.IO.FileAttributes = System.IO.File.GetAttributes(filePath) If (attrib And System.IO.FileAttributes.Compressed) = System.IO.FileAttributes.Compressed Then Return True Else Return False End If End Function
#6
Re: File Attributes
Posted 29 July 2007 - 09:52 PM
I agree with the others, using the System.IO.FileInfo is really the preferred way of getting file attributes (over GetFileAttributesEx).
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|