B4J Question file modified by ?

i was wondering if there was anyway for b4j to detect who last modified a file ? ether the computer name or the user name would be good.
 

zed

Active Member
Licensed User
Try this code to get the system environment.
Maybe something will be useful to you in the results.
B4J:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    
    Dim SystemEnvironment As Map = getSystemEnvironment
    For Each Key As String In SystemEnvironment.Keys
        Log($"${Key} = ${SystemEnvironment.Get(Key)}"$)
    Next
End Sub


Sub getSystemEnvironment As Map
    Dim jo As JavaObject
    jo.InitializeStatic("java.lang.System")
    Dim Env As Map = jo.RunMethod("getenv", Null)
    Return Env
End Sub
 
Upvote 0
walt61, that seems to be what i'm after, the extended file attributes. the owner is about the best i can do i believe. its been awhile since i worked in b4j and i'm going to have to figure out how to apply the jar file you mentioned and apply it. but it looks right. thanks.
 
Upvote 0
i've added the jar and xml to my additional lib folder, i have checked it on in the library manager. but i still don't know how to use it. do you have example code ? do i declare a class of some sorts ? then use it ? seems like i should declare a variable to hold the info. then call a method to get the info.
 
Upvote 0

walt61

Active Member
Licensed User
Longtime User
Just had a look at the codeproject page on which the library is based and it seems it looks for the owner by shelling 'cmd'. I couldn't test it, but have the impression that this should work (it does for e.g. property AbsolutePath; I'm on Linux with Wine, and don't have a 'cmd' there):
B4X:
    Dim fp As fileproperties
    fp.FileInfo("C:\test.txt") ' This appears to be the equivalent of the trusted 'Initialize' method
    Log(fp.Owner)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…