Search code examples
c#filexamarinxamarin.androidmvvmcross

MvvmCross.Plugins.File write/read on default folder


I am trying to use MvvmCross.Plugins.File to save images that I retrieved from my web service (with Cross platform advantage). It is said on the documentation the plugin has the default folder (that depends on the OS) for writing and reading the data. However, the WriteFile and TryReadBinaryFile method (from IMvxFileStore) needs path parameter.

var filestore = Mvx.Resolve<IMvxFileStore>();
filestore.WriteFile("WhatIsThePath", myfile);

Could you guys help me, what should I write if I want to use the default value? Is there any good examples or tutorials for this? Been searching for examples on google and MvvmCross GitHub repo, but could not find one.


Solution

  • The plugin calls ToFullPath internally which combines the path you provide, with the default path.

    This means, if the default path is /storage/0/, and the path you provide in the argument is pictures/mypicture.jpg the path will end up as: /storage/0/pictures/mypicture.jpg.

    So just as the documentation says, what you provide as path is relative to the default for the plugin.

    The default path, can currently only be changed for the WPF version of the plugin. If you need to change this on other platforms, feel free to create an issue about this in our GitHub issues requesting this.