3

In my application, I will provide two options to load files as FromResource() and FromFile() method. In the first method, the file should be marked as EmbeddedResource and loaded through the FromResource() method. The second option, user don't want to keep the file as EmbeddedResource and it directly refers to the file path. If users enter only a file name rather than an absolute path, it will directly access the file from the application's Resources folder, like "Resources.{filename}".

Can you please guide me on how to access/read Resources folder's files in the .NET MAUI?

  • it's unclear what you're trying to accomplish. What is the purpose of allowing the user to choose the source? You can't write to files or resources at runtime - they are fixed at compile time. – Jason May 24 '22 at 13:06
  • @Jason Users have to give input data as a JSON file and assign it to the custom control that is presented in the app. So, we created a custom control with Source property and the user needs to assign the file source either embedded or local file. If the user added the file in the app's Resource folder without marking it as embedded, how to access it? – sheik abuthaheer May 24 '22 at 14:53
  • 1
    the user cannot add anything to the Resources. They are not writable at runtime. Anything added by the user at runtime would need to be stored as a file in one of the app's data folders – Jason May 24 '22 at 15:29
  • [File Picker](https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/storage/file-picker). And [Essentials File System Helpers](https://learn.microsoft.com/en-us/xamarin/essentials/file-system-helpers). NOTE: for Maui, don't do `using Xamarin.Essentials;` as shown in that Xamarin doc. `FileSystem` should be found automatically by Maui. (Its in namespace Microsoft.Maui.Storage.) – ToolmakerSteve May 24 '22 at 20:28

0 Answers0