Issue
I am new to mobile development and am writing a .NET MAUI Android application and part of that application needs to be able to sync files. This device has no network connection and will be docked (connected to a PC) where files that were created on the device are fetched from the PC and then the PC will then load a new file to the device. This sync process will happen from a seperate desktop application.
Looking at the documentation on the File system helpers, I don't see a clearly documented way to write a file to a directory that is visible in File Explorer when I connect the device.
I am looking for a way to write to a directory that then is visible once docked. I don't want to open a dialog for a user to pick the save location as I want that location to always be consistent. Any ideas of where I can get a file path of a "public" folder to read and write files to?
Solution
Doing additional digging, this did the trick.
var docsDirectory = Android.App.Application.Context.GetExternalFilesDir(Android.OS.Environment.DirectoryDocuments);
File.WriteAllText($"{docsDirectory.AbsoluteFile.Path}/atextfile.txt", "contents are here");
Answered By - Justin
Answer Checked By - Clifford M. (JavaFixing Volunteer)