B4J Question File attribute?

boten

Active Member
Licensed User
Longtime User
Can get file date & size with:

File.LastModified (Dir As String, FileName As String) As Long
File.Size (Dir As String, FileName As String) As Long

Can I get the file's attribute? (hidden, read-only)?
 
Code:
Log(IsHidden(File.Combine("C:\temp", "1.png")))
Log(CanWrite(File.Combine("C:\temp", "1.png")))


Sub IsHidden (Path As String) As Boolean
   Dim jo As JavaObject
   Return jo.InitializeNewInstance("java.io.File", Array(Path)).RunMethod("isHidden", Null)
End Sub

Sub CanWrite (Path As String) As Boolean
   Dim jo As JavaObject
   Return jo.InitializeNewInstance("java.io.File", Array(Path)).RunMethod("canWrite", Null)
End Sub
 
Upvote 0
The jFileWatcher library allows you to easily get and set many attributes of files and folders (including hiddenness, read-onlyness, etc...).
 
Upvote 0
Back
Top