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)?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
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

Roycefer

Well-Known Member
Licensed User
Longtime User
The jFileWatcher library allows you to easily get and set many attributes of files and folders (including hiddenness, read-onlyness, etc...).
 
Upvote 0
Top