Bug 60549 - How to get app modified date and created date from Xamarin.iOS
Summary: How to get app modified date and created date from Xamarin.iOS
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 11.0 (xcode9)
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2017-11-07 13:32 UTC by Chetan jolly
Modified: 2017-11-07 15:59 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Chetan jolly 2017-11-07 13:32:05 UTC
Hi I am also facing issue to get the installed app Date and Time of application in iOS 10.3 and iOS  11, with this type of code

NSString pathToInfoPlist = (NSString) NSBundle.MainBundle.PathForResource(Info, plist);
NSString pathToAppBundle = pathToInfoPlist.DeleteLastPathComponent();
NSFileAttributes fileAttributes = NSFileManager.DefaultManager.GetAttributes(pathToAppBundle);
DateTime updateDate = fileAttributes.ModificationDate.ToDateTime();
DateTime lastUpdateDate = new DateTime(updateDate.Year, updateDate.Month, updateDate.Day, updateDate.Hour, updateDate.Minute, updateDate.Second, updateDate.Millisecond);
return lastUpdateDate;

In this i am getting dateTime as 1-Jan-1970,

And then i have tried to remove
NSString pathToAppBundle = pathToInfoPlist.DeleteLastPathComponent();

and taking ModificationDate from Info.plist, then i am able to get the correct dateTime as 7-Nov-2017,

As in first statement adding path to Info.plist:


and in second statement deleting Info.plist and setting AppBundlePath :


So, what i should do in this as we are taking DateTime from IOS.app file but that time is coming as 1-Jan-2017, but if i am taking ModificationDate from Info.plist it is giving me current value.

Please suggest me to getting ModifiedDate from Installed app.
Comment 1 Alex Soto [MSFT] 2017-11-07 15:59:01 UTC
Hello, this is not a bug in Xamarin.iOS, you would get the same result if you test in Xcode using ObjC, this is because `attributesOfItemAtPath:error:` which is the underlying selector used by `NSFileManager.DefaultManager.GetAttributes (string)` stopped providing the information after iOS 10.2 release IIRC (I am sure you can google this). On a side note this will work on the simulator because it does not have the same restrictions that iOS on devices does.

About the right solution to this, well that depends on your use case, you could just point to Info.plist and rely on those values, you could also check the Documents directory instead or you could do your own thing on the first launch and store these values in NSUserDefaults[A] or with the settings plugin[B].

[A]: https://developer.xamarin.com/guides/ios/application_fundamentals/user-defaults/
[B]: https://github.com/jamesmontemagno/SettingsPlugin

The broader developer community would be the best and quickest place for additional troubleshooting help on this issue.

Posting a question on Stack Overflow [0] or the Xamarin Forums [1] would be the best next step if you require more ideas on how to solve this particular issue.

[0] https://stackoverflow.com/questions/tagged/xamarin
[1] https://forums.xamarin.com/categories/ios

(Investigation by the Xamarin team in the bug tracker for an issue like this would usually require that the reporter include additional background info to hint that Xamarin is behaving differently compared to Xcode.)

In case it might also be a helpful reference, you can find some general recommendations on the best places to ask various kinds of questions about Xamarin on: