Search code examples
ios5xamarin.iosnsfilemanager

MonoTouch: How to set the "do not back up" attribute


I am trying to follow the following guidance from Apple about local file storage. How do I set the "do not back" attribute on files created by my apps in MonoTouch?

Technical docs here, but I can't find this in MonoTouch: https://developer.apple.com/library/ios/#qa/qa1719/_index.html

Use the "do not back up" attribute for specifying files that should remain on device, even in low storage situations. Use this attribute with data that can be recreated but needs to persist even in low storage situations for proper functioning of your app or because customers expect it to be available during offline use. This attribute works on marked files regardless of what directory they are in, including the Documents directory. These files will not be purged and will not be included in the user's iCloud or iTunes backup. Because these files do use on-device storage space, your app is responsible for monitoring and purging these files periodically."


Solution

  • This is available since MonoTouch 5.2 (and iOS 5.0.1) inside the MonoTouch.Foundation.NSFileManager type, methods SetSkipBackupAttribute and GetSkipBackupAttribute.