Hello,
Welcome to our Microsoft Q&A platform!
Please change your var localFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
to var localFolder= FileSystem.AppDataDirectory;
, **
FileSystem.AppDataDirectory** comes from Xamarin.Essentialas.
Then open your fille_provider_paths.xml
, change files-path
like following code.
<?xml version="1.0" encoding="utf-8" ?>
<paths>
<files-path name="files" path="."/>
</paths>
Note: Provider path for a specific path as followings:
<files-path/> --> Context.getFilesDir()
<cache-path/> --> Context.getCacheDir()
If you have some doubts about using FileProvider, you can refer to google's document.
And if you want to share this text file to other application, you need to add chooserIntent.SetFlags(ActivityFlags.NewTask);
for chooserIntent
in the Share.cs
. Otherwise, you will get following exception.
Android.Util.AndroidRuntimeException: 'Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?'
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.