For the majority of the apps I’ve worked on, there’s been a requirement to store some sort of data in files. Whether it’s images from the camera or gallery, a database or just log files it seems to come up more often than not.

When you’re working in the simulator/emulator environment during development it’s not too difficult to get access to these files so you can interrogate them and work on things from there.

When your app is in the hands of testers, or even actual users, this isn’t such a simple thing.

An approach I’ve been using for a while now (and often this is just in test builds on a screen “Developer Settings” or something) is to have an option to zip everything I want up to help with debugging and then having the user share it, whether that’s via email or Skype or whatever.

This used to be a bit more complicated in the days of PCL’s and Shared Projects that required platform specific implementations of the various parts, but with .NET Standard and a little bit of help from Xamarin.Essentials, this is now a breeze.

Once you’ve added the utility method, incorporating this functionality in your app is as simple as:

There is some fiddling around with where the files are and setting the temporary paths, but to actually zip things up it’s just a matter of:

Then just add the Xamarin.Essentials NuGet* package to all projects and to present the user a standard share dialog on each platform with the zip file just created is as simple as:

* Note: If you’re using a version of Xamarin.Essentials < 1.3.0 then you’ll also need to add the following code to your App.xaml.cs or App.cs during initialisation:

The full source code of the utility is:

This is a nice and succinct way of wrapping some files and exporting them so you can see what’s happening on the users actual device and app set up rather than trying to guess and facing the old cliché: works on my machine.

I hope this is helpful for some of you. As I mentioned, I add a basic Developer Settings screen in most apps I work on (one day I might even write about it and share a sample you can just drop in, if there’s ever time…) as they get more complex and add this in as a way for users to just send through a snapshot of their environment so I can then further work through what they’re doing.

You can even get more complicated and change the above to actually import their data into the app (there’s extract functionality within the ZipeFile class) directly to your device and run their scenario up for yourself.

If you want the entire working example, please have a look here on GitHub.