B4J Question B4J: Getting file detailed information [solved, sort of...]

Didier9

Well-Known Member
Licensed User
Longtime User
I need to get a file's detailed information (actual file size, creation date) equivalent to what we get from a DIR command at the Command Prompt, or from the File->Property menu in Explorer.
Any suggestion appreciated.
 

Didier9

Well-Known Member
Licensed User
Longtime User
Wow, I have been busy and missed all the comments...

I could not unwrap myself out of the shell string issue, so after spending way too much time with that, I made what any sensible soul would do under similar circumstances, I gave up...

But since I only needed file size and lastModifiedTime, I fixed it using FileWatcher (for the modification time, very easy) and for the file size, I just gobble the file into a byte array and use the size of the array. That's pretty ugly but it matches exactly what Windows is reporting so I am going to call it done, considering that it is not intended to use in a product that I will release, it is just a utility for me, and I only deal with 2 or 3 dozen files at a time that are < 100kB each, so it's quick.
Other advantage is that I may end up having to do a crc on the files, so having them in a byte array is just a function call away from having that too :)

Thank you Mark in particular who took it personally and tried very hard. Not sure why we are getting different results, I will dig into that some more at some point.

Thank you all for the suggestions, I will go over everything in the next few days. There were multiple useful tidbits and suggestions that I may use for other things.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
It doesn't have the creation date which you mentioned in your first post, but it has last modified and size:
B4X:
File.LastModified(Dir As String, FileName As String)
File.Size(Dir As String, FileName As String)
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
Actually I needed the lastModified date, so it's just what I needed.
I can't believe I missed that...
 
Upvote 0
Top