How to check the date on a file that is create

Hi
i need check the date on a file that is create so i can open last date

I believe that what you are looking for is folderitem.creationdatetime.
link to documentation

but you might want the MODIFIED date instead… .depending on what you need to do

ok
thanks

Under v2019r2 on MacOS 10.14.6, the example lines in the above-linked documentation…
Var f As New FolderItem
MessageBox(f.CreationDateTime.ToString(DateTime.FormatStyles.Short, DateTime.FormatStyles.None)

… give the following error message:
There is more than one method with this name but this does not match any of the available signatures.

Why does this simple line of code not work? (I just ran across this exact problem in “Introduction to Programming with Xojo”, p 143.)

I believe you forgot the closing parenthesis.

You’re absolutely right. I forgot that I had corrected the code as it appeared in the documentation – which is what I looked up and copied/pasted when I posted the above.

But the code I actually tried did have the closing parenthesis…and gave the error I showed above.

(I hope I’m still missing something as simple as a parenthesis!)

Where do you assign f any valid folderItem ? As it stands, f is nil in your code.

I agree that as it stands, f is nil in the code example given in the documentation. But shouldn’t the fact that f is nil only be an issue at runtime? The two lines above won’t even compile.

Here is the code that I was actually using, boiled down to show this problem:

[code]Var myFile As FolderItem
Var d As OpenFileDialog
d = New OpenFileDialog

myFile = d.ShowModal

If myFile <> Nil Then
MessageBox(myFile.CreationDateTime.ToString(DateTime.FormatStyles.Short, DateTime.FormatStyles.None))
End If[/code]

As simple as that is, it still gives the error message.

You forgot the locale.

This compiles and works:

[code]Var myFile As FolderItem
Var d As OpenFileDialog
d = New OpenFileDialog

myFile = d.ShowModal

If myFile <> Nil Then
MessageBox(myFile.CreationDateTime.ToString(Nil,DateTime.FormatStyles.Short, DateTime.FormatStyles.None))
End If[/code]
http://documentation.xojo.com/api/data_types/datetime.html#datetime-tostring

I see that this is new to v2019r2, which I suppose is why what’s in “Introduction to Programming with Xojo” doesn’t work any more. Had the error message mentioned something about “Locale” (which I’d never heard of until this minute), I might have had a chance to look up the term and discover the problem.

Until I renewed my Xojo license recently, I’d been using 2016r4 for the very little bit of programming I’ve done.

Thank you very much for being patient with me (and for knowing about this new feature)!

Your first reflex should always be to reach for the LR. Especially since 2019R2 has many, many new features.

Or you do not download the one compliant to 19r2…

The only “Introduction to Programming with Xojo” offered on the Xojo website has a creation date of 9 October 2019. I had reasonably (I thought) expected that to be recent enough to be compliant with 19r2. I was wrong. It is not. For example, in that edition you will note on p 143 that, apropos of this discussion, there is no mention of “locale” in the use of CreationDate.ToString.

Michel Bujardet’s advice – always to reach for the LR – seems best right now.

Robert,

API 2.0 just came out this month. The documentation was adapted from API 1.0 to API 2.0. Surely, there are still a few glitches here and there, especially since there are thousands of pages of documentation. We all expect perfection, but being realistic also means that we should be tolerant for the occasional error in documentation. If and when you find inconsistencies and/or errors, please file a feedback request. This is the best way to communicate the problem to Xojo and get it fixed. Documentation errors are treated as bugs, and they are generally fixed very quickly. You should see a list of documentation fixes in the release notes for the next release.

The whole community will gain from you reporting errors when you find them.

As I mentioned above, I am returning to Xojo after being away for years, and I didn’t realize the scope of the recent improvements.

I appreciate your comments, Louis, and also the “get it fixed” spirit. I will, as you suggest, provide feedback to help improve Xojo.

Thank you!