├── SafMaui
├── Resources
│ ├── Fonts
│ │ ├── OpenSans-Regular.ttf
│ │ └── OpenSans-Semibold.ttf
│ ├── AppIcon
│ │ ├── appicon.svg
│ │ └── appiconfg.svg
│ ├── Raw
│ │ └── AboutAssets.txt
│ ├── Splash
│ │ └── splash.svg
│ ├── Styles
│ │ ├── Colors.xaml
│ │ └── Styles.xaml
│ └── Images
│ │ └── dotnet_bot.svg
├── AppShell.xaml.cs
├── Properties
│ └── launchSettings.json
├── App.xaml.cs
├── archiv.bat
├── Platforms
│ └── Android
│ │ ├── Resources
│ │ └── values
│ │ │ └── colors.xml
│ │ ├── MainApplication.cs
│ │ ├── AndroidManifest.xml
│ │ ├── MainActivity.cs
│ │ └── Service
│ │ └── SafService.cs
├── AppShell.xaml
├── Service
│ └── SafService.cs
├── MauiProgram.cs
├── App.xaml
├── SafMaui.sln
├── MainPage.xaml
├── SafMaui.csproj
└── MainPage.xaml.cs
├── FilePickerTest
├── Resources
│ ├── Fonts
│ │ ├── OpenSans-Regular.ttf
│ │ └── OpenSans-Semibold.ttf
│ ├── AppIcon
│ │ ├── appicon.svg
│ │ └── appiconfg.svg
│ ├── Raw
│ │ └── AboutAssets.txt
│ ├── Splash
│ │ └── splash.svg
│ ├── Styles
│ │ ├── Colors.xaml
│ │ └── Styles.xaml
│ └── Images
│ │ └── dotnet_bot.svg
├── AppShell.xaml.cs
├── Properties
│ └── launchSettings.json
├── App.xaml.cs
├── Platforms
│ ├── Android
│ │ ├── Resources
│ │ │ └── values
│ │ │ │ └── colors.xml
│ │ ├── MainApplication.cs
│ │ ├── MainActivity.cs
│ │ └── AndroidManifest.xml
│ ├── iOS
│ │ ├── AppDelegate.cs
│ │ ├── Program.cs
│ │ └── Info.plist
│ ├── MacCatalyst
│ │ ├── AppDelegate.cs
│ │ ├── Program.cs
│ │ └── Info.plist
│ ├── Windows
│ │ ├── App.xaml
│ │ ├── app.manifest
│ │ ├── App.xaml.cs
│ │ └── Package.appxmanifest
│ └── Tizen
│ │ ├── Main.cs
│ │ └── tizen-manifest.xml
├── AppShell.xaml
├── MauiProgram.cs
├── App.xaml
├── MainPage.xaml
├── MainPage.xaml.cs
└── FilePickerTest.csproj
├── archiv.bat
├── LICENSE.txt
├── SafMaui.sln
├── README.md
├── .gitattributes
└── .gitignore
/SafMaui/Resources/Fonts/OpenSans-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papnak/SafMaui/HEAD/SafMaui/Resources/Fonts/OpenSans-Regular.ttf
--------------------------------------------------------------------------------
/SafMaui/Resources/Fonts/OpenSans-Semibold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papnak/SafMaui/HEAD/SafMaui/Resources/Fonts/OpenSans-Semibold.ttf
--------------------------------------------------------------------------------
/FilePickerTest/Resources/Fonts/OpenSans-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papnak/SafMaui/HEAD/FilePickerTest/Resources/Fonts/OpenSans-Regular.ttf
--------------------------------------------------------------------------------
/FilePickerTest/Resources/Fonts/OpenSans-Semibold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/papnak/SafMaui/HEAD/FilePickerTest/Resources/Fonts/OpenSans-Semibold.ttf
--------------------------------------------------------------------------------
/SafMaui/AppShell.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace SafMaui;
2 |
3 | public partial class AppShell : Shell
4 | {
5 | public AppShell()
6 | {
7 | InitializeComponent();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/SafMaui/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "Windows Machine": {
4 | "commandName": "MsixPackage",
5 | "nativeDebugging": false
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/FilePickerTest/AppShell.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace FilePickerTest;
2 |
3 | public partial class AppShell : Shell
4 | {
5 | public AppShell()
6 | {
7 | InitializeComponent();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/FilePickerTest/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "Windows Machine": {
4 | "commandName": "MsixPackage",
5 | "nativeDebugging": false
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/SafMaui/App.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace SafMaui;
2 |
3 | public partial class App : Application
4 | {
5 | public App()
6 | {
7 | InitializeComponent();
8 |
9 | MainPage = new AppShell();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/FilePickerTest/App.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace FilePickerTest;
2 |
3 | public partial class App : Application
4 | {
5 | public App()
6 | {
7 | InitializeComponent();
8 |
9 | MainPage = new AppShell();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/SafMaui/archiv.bat:
--------------------------------------------------------------------------------
1 | c:\Programme\7-Zip\7z a "c:\Users\hrado\iCloudDrive\Archive\SAF_MAUI\\SAF_MAUI_%DATE%_%TIME:~0,2%.%TIME:~3,2%.%TIME:~-5%.zip" ..\* -xr!bin -xr!obj -xr!Videos -xr!APK -xr!Airports -xr!Screenshots -xr!Doc
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/SafMaui/Resources/AppIcon/appicon.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/SafMaui/Platforms/Android/Resources/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #512BD4
4 | #2B0B98
5 | #2B0B98
6 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/Android/Resources/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #512BD4
4 | #2B0B98
5 | #2B0B98
6 |
--------------------------------------------------------------------------------
/FilePickerTest/Resources/AppIcon/appicon.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/iOS/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using Foundation;
2 |
3 | namespace FilePickerTest;
4 |
5 | [Register("AppDelegate")]
6 | public class AppDelegate : MauiUIApplicationDelegate
7 | {
8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
9 | }
10 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/MacCatalyst/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using Foundation;
2 |
3 | namespace FilePickerTest;
4 |
5 | [Register("AppDelegate")]
6 | public class AppDelegate : MauiUIApplicationDelegate
7 | {
8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
9 | }
10 |
--------------------------------------------------------------------------------
/archiv.bat:
--------------------------------------------------------------------------------
1 | rem zip the solution after every successful built
2 | c:\Programme\7-Zip\7z a "c:\Users\hrado\iCloudDrive\Archive\SAF_MAUI\\SAF_MAUI_%DATE%_%TIME:~0,2%.%TIME:~3,2%.%TIME:~-5%.zip" ..\* -xr!.git -xr!bin -xr!obj -xr!Videos -xr!APK -xr!Airports -xr!Screenshots -xr!Doc
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/Windows/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/Tizen/Main.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Maui;
3 | using Microsoft.Maui.Hosting;
4 |
5 | namespace FilePickerTest;
6 |
7 | class Program : MauiApplication
8 | {
9 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
10 |
11 | static void Main(string[] args)
12 | {
13 | var app = new Program();
14 | app.Run(args);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/SafMaui/Platforms/Android/MainApplication.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Runtime;
3 |
4 | namespace SafMaui;
5 |
6 | [Application]
7 | public class MainApplication : MauiApplication
8 | {
9 | public MainApplication(IntPtr handle, JniHandleOwnership ownership)
10 | : base(handle, ownership)
11 | {
12 | }
13 |
14 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
15 | }
16 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/Android/MainApplication.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Runtime;
3 |
4 | namespace FilePickerTest;
5 |
6 | [Application]
7 | public class MainApplication : MauiApplication
8 | {
9 | public MainApplication(IntPtr handle, JniHandleOwnership ownership)
10 | : base(handle, ownership)
11 | {
12 | }
13 |
14 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
15 | }
16 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/iOS/Program.cs:
--------------------------------------------------------------------------------
1 | using ObjCRuntime;
2 | using UIKit;
3 |
4 | namespace FilePickerTest;
5 |
6 | public class Program
7 | {
8 | // This is the main entry point of the application.
9 | static void Main(string[] args)
10 | {
11 | // if you want to use a different Application Delegate class from "AppDelegate"
12 | // you can specify it here.
13 | UIApplication.Main(args, null, typeof(AppDelegate));
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/MacCatalyst/Program.cs:
--------------------------------------------------------------------------------
1 | using ObjCRuntime;
2 | using UIKit;
3 |
4 | namespace FilePickerTest;
5 |
6 | public class Program
7 | {
8 | // This is the main entry point of the application.
9 | static void Main(string[] args)
10 | {
11 | // if you want to use a different Application Delegate class from "AppDelegate"
12 | // you can specify it here.
13 | UIApplication.Main(args, null, typeof(AppDelegate));
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/SafMaui/AppShell.xaml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/Android/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Content.PM;
3 | using Android.OS;
4 |
5 | namespace FilePickerTest;
6 |
7 | [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
8 | public class MainActivity : MauiAppCompatActivity
9 | {
10 | }
11 |
--------------------------------------------------------------------------------
/FilePickerTest/AppShell.xaml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/SafMaui/Service/SafService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | // SafService Shared Project
8 |
9 | namespace SafMaui
10 | {
11 | #if ANDROID
12 |
13 | public partial class SafService
14 | {
15 | public partial void ShowUriBrowser();
16 | public partial void CopyToExternalStorage(string intPath, string fname);
17 | public partial void CopyFromExternalStorage(string intPath, string fname);
18 |
19 | }
20 | #endif
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/SafMaui/MauiProgram.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Logging;
2 |
3 | namespace SafMaui;
4 |
5 | public static class MauiProgram
6 | {
7 | public static MauiApp CreateMauiApp()
8 | {
9 | var builder = MauiApp.CreateBuilder();
10 | builder
11 | .UseMauiApp()
12 | .ConfigureFonts(fonts =>
13 | {
14 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
15 | fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
16 | });
17 |
18 | #if DEBUG
19 | builder.Logging.AddDebug();
20 | #endif
21 |
22 | return builder.Build();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/FilePickerTest/MauiProgram.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Logging;
2 |
3 | namespace FilePickerTest;
4 |
5 | public static class MauiProgram
6 | {
7 | public static MauiApp CreateMauiApp()
8 | {
9 | var builder = MauiApp.CreateBuilder();
10 | builder
11 | .UseMauiApp()
12 | .ConfigureFonts(fonts =>
13 | {
14 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
15 | fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
16 | });
17 |
18 | #if DEBUG
19 | builder.Logging.AddDebug();
20 | #endif
21 |
22 | return builder.Build();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/SafMaui/Platforms/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/SafMaui/App.xaml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/SafMaui/Resources/Raw/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories). Deployment of the asset to your application
3 | is automatically handled by the following `MauiAsset` Build Action within your `.csproj`.
4 |
5 |
6 |
7 | These files will be deployed with you package and will be accessible using Essentials:
8 |
9 | async Task LoadMauiAsset()
10 | {
11 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt");
12 | using var reader = new StreamReader(stream);
13 |
14 | var contents = reader.ReadToEnd();
15 | }
16 |
--------------------------------------------------------------------------------
/FilePickerTest/Resources/Raw/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories). Deployment of the asset to your application
3 | is automatically handled by the following `MauiAsset` Build Action within your `.csproj`.
4 |
5 |
6 |
7 | These files will be deployed with you package and will be accessible using Essentials:
8 |
9 | async Task LoadMauiAsset()
10 | {
11 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt");
12 | using var reader = new StreamReader(stream);
13 |
14 | var contents = reader.ReadToEnd();
15 | }
16 |
--------------------------------------------------------------------------------
/FilePickerTest/App.xaml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/Windows/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
11 | true/PM
12 | PerMonitorV2, PerMonitor
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/Tizen/tizen-manifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | maui-appicon-placeholder
7 |
8 |
9 |
10 |
11 | http://tizen.org/privilege/internet
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/Windows/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.UI.Xaml;
2 |
3 | // To learn more about WinUI, the WinUI project structure,
4 | // and more about our project templates, see: http://aka.ms/winui-project-info.
5 |
6 | namespace FilePickerTest.WinUI;
7 |
8 | ///
9 | /// Provides application-specific behavior to supplement the default Application class.
10 | ///
11 | public partial class App : MauiWinUIApplication
12 | {
13 | ///
14 | /// Initializes the singleton application object. This is the first line of authored code
15 | /// executed, and as such is the logical equivalent of main() or WinMain().
16 | ///
17 | public App()
18 | {
19 | this.InitializeComponent();
20 | }
21 |
22 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/MacCatalyst/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UIDeviceFamily
6 |
7 | 1
8 | 2
9 |
10 | UIRequiredDeviceCapabilities
11 |
12 | arm64
13 |
14 | UISupportedInterfaceOrientations
15 |
16 | UIInterfaceOrientationPortrait
17 | UIInterfaceOrientationLandscapeLeft
18 | UIInterfaceOrientationLandscapeRight
19 |
20 | UISupportedInterfaceOrientations~ipad
21 |
22 | UIInterfaceOrientationPortrait
23 | UIInterfaceOrientationPortraitUpsideDown
24 | UIInterfaceOrientationLandscapeLeft
25 | UIInterfaceOrientationLandscapeRight
26 |
27 | XSAppIconAssets
28 | Assets.xcassets/appicon.appiconset
29 |
30 |
31 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) [year] [fullname]
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | LSRequiresIPhoneOS
6 |
7 | UIDeviceFamily
8 |
9 | 1
10 | 2
11 |
12 | UIRequiredDeviceCapabilities
13 |
14 | arm64
15 |
16 | UISupportedInterfaceOrientations
17 |
18 | UIInterfaceOrientationPortrait
19 | UIInterfaceOrientationLandscapeLeft
20 | UIInterfaceOrientationLandscapeRight
21 |
22 | UISupportedInterfaceOrientations~ipad
23 |
24 | UIInterfaceOrientationPortrait
25 | UIInterfaceOrientationPortraitUpsideDown
26 | UIInterfaceOrientationLandscapeLeft
27 | UIInterfaceOrientationLandscapeRight
28 |
29 | XSAppIconAssets
30 | Assets.xcassets/appicon.appiconset
31 |
32 |
33 |
--------------------------------------------------------------------------------
/FilePickerTest/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
11 |
12 |
17 |
18 |
22 |
23 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/SafMaui/SafMaui.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 25.0.1704.2
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafMaui", "SafMaui.csproj", "{11082BF3-B1F6-4C84-8AEA-3D2F084866E6}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {11082BF3-B1F6-4C84-8AEA-3D2F084866E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {11082BF3-B1F6-4C84-8AEA-3D2F084866E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {11082BF3-B1F6-4C84-8AEA-3D2F084866E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {11082BF3-B1F6-4C84-8AEA-3D2F084866E6}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {E1C5B98E-EE29-42B9-A7CC-60C7E56CF492}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/SafMaui/Platforms/Android/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Content;
3 | using Android.Content.PM;
4 | using Android.OS;
5 | using Android.Runtime;
6 | using PortableStorage.Droid;
7 |
8 | namespace SafMaui;
9 |
10 | [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
11 | public class MainActivity : MauiAppCompatActivity
12 | {
13 | public const int BROWSE_REQUEST_CODE = 100;
14 | internal static MainActivity Instance { get; private set; }
15 |
16 |
17 | protected override void OnCreate(Bundle savedInstanceState)
18 | {
19 | base.OnCreate(savedInstanceState);
20 | Instance = this;
21 |
22 | }
23 |
24 |
25 | protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
26 | {
27 | base.OnActivityResult(requestCode, resultCode, data);
28 |
29 | try
30 | {
31 | if (requestCode == BROWSE_REQUEST_CODE && resultCode == Result.Ok)
32 | SafService.StorageUri = SafStorageHelper.ResolveFromActivityResult(this, data);
33 |
34 | }
35 | catch (Exception e)
36 | {
37 | Console.WriteLine(e);
38 | }
39 |
40 | }
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/SafMaui/Resources/Splash/splash.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/SafMaui/Resources/AppIcon/appiconfg.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/FilePickerTest/Resources/AppIcon/appiconfg.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/FilePickerTest/Resources/Splash/splash.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/FilePickerTest/Platforms/Windows/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | $placeholder$
15 | User Name
16 | $placeholder$.png
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/SafMaui/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
11 |
12 |
16 |
17 |
21 |
22 |
23 |
27 |
28 |
34 |
35 |
41 |
42 |
48 |
49 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/SafMaui.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.0.31611.283
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SafMaui", "SafMaui\SafMaui.csproj", "{E4A141D4-E5CA-4CF6-A2BD-99081F00938D}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FilePickerTest", "FilePickerTest\FilePickerTest.csproj", "{49518EA8-5C67-4E2A-B476-3C063FD8474F}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7B3E6D32-F049-41F0-B6D1-911CE73F7CCE}"
11 | ProjectSection(SolutionItems) = preProject
12 | archiv.bat = archiv.bat
13 | README.md = README.md
14 | EndProjectSection
15 | EndProject
16 | Global
17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
18 | Debug|Any CPU = Debug|Any CPU
19 | Release|Any CPU = Release|Any CPU
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {E4A141D4-E5CA-4CF6-A2BD-99081F00938D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {E4A141D4-E5CA-4CF6-A2BD-99081F00938D}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {E4A141D4-E5CA-4CF6-A2BD-99081F00938D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
25 | {E4A141D4-E5CA-4CF6-A2BD-99081F00938D}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {E4A141D4-E5CA-4CF6-A2BD-99081F00938D}.Release|Any CPU.Build.0 = Release|Any CPU
27 | {E4A141D4-E5CA-4CF6-A2BD-99081F00938D}.Release|Any CPU.Deploy.0 = Release|Any CPU
28 | {49518EA8-5C67-4E2A-B476-3C063FD8474F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {49518EA8-5C67-4E2A-B476-3C063FD8474F}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {49518EA8-5C67-4E2A-B476-3C063FD8474F}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
31 | {49518EA8-5C67-4E2A-B476-3C063FD8474F}.Release|Any CPU.ActiveCfg = Release|Any CPU
32 | {49518EA8-5C67-4E2A-B476-3C063FD8474F}.Release|Any CPU.Build.0 = Release|Any CPU
33 | {49518EA8-5C67-4E2A-B476-3C063FD8474F}.Release|Any CPU.Deploy.0 = Release|Any CPU
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | GlobalSection(ExtensibilityGlobals) = postSolution
39 | SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
40 | EndGlobalSection
41 | EndGlobal
42 |
--------------------------------------------------------------------------------
/SafMaui/Resources/Styles/Colors.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 | #512BD4
8 | #DFD8F7
9 | #2B0B98
10 | White
11 | Black
12 | #E1E1E1
13 | #C8C8C8
14 | #ACACAC
15 | #919191
16 | #6E6E6E
17 | #404040
18 | #212121
19 | #141414
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | #F7B548
35 | #FFD590
36 | #FFE5B9
37 | #28C2D1
38 | #7BDDEF
39 | #C3F2F4
40 | #3E8EED
41 | #72ACF1
42 | #A7CBF6
43 |
44 |
--------------------------------------------------------------------------------
/FilePickerTest/Resources/Styles/Colors.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 | #512BD4
8 | #DFD8F7
9 | #2B0B98
10 | White
11 | Black
12 | #E1E1E1
13 | #C8C8C8
14 | #ACACAC
15 | #919191
16 | #6E6E6E
17 | #404040
18 | #212121
19 | #141414
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | #F7B548
35 | #FFD590
36 | #FFE5B9
37 | #28C2D1
38 | #7BDDEF
39 | #C3F2F4
40 | #3E8EED
41 | #72ACF1
42 | #A7CBF6
43 |
44 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### How to read/write from/to External Storage with .NET MAUI?
2 |
3 | Definition:
4 |
5 | **Internal Storage**: An Android App lives in a sandbox. Only the app can read and write data from/to this sandbox.
6 | **External Storage**: Is shared storage e.g. the documents or downloads folder and OTG, cloud and SD cards as well.
7 |
8 | But how to access External Storage?
9 |
10 | This works with the **Storage Access Framework (SAF)**
11 | Google introduced it with Android 4.4 (API level 19)
12 | Starting with API Level 24 Android 7 Nougat the SAF is the only way to access external memory.
13 |
14 | Here you can find some infos about SAF
15 |
16 | https://commonsware.com/Jetpack/pages/chap-content-001.html
17 |
18 | https://developer.android.com/guide/topics/providers/document-provider
19 |
20 | https://developer.android.com/training/data-storage/shared/documents-files
21 |
22 | I was chaseing the Internet for a SAF wrapper for .Net Maui and found a package of
23 |
24 | Mohammad Nikravan (madnik7) on: https://github.com/madnik7/PortableStorage
25 |
26 | madnik7 has done a really good job. Unfortunatelly it is barely commented and documented.
27 |
28 | In my example I concentrate on two things:
29 |
30 | - Copy a file from Internal Storage (e.g. FileSystem.Current.AppDataDirectory) to the external Storage (e.g /storage/emulated/0/Download).
31 | - Copy a file from External Storage to the Internal Storage.
32 |
33 | You need to include the NuGet PortableStorage.Android package.
34 |
35 | The SAF is URI based. To retrieve an URI the SAF provides a browser. With this browser the user selects a path in the External Storage.
36 | The browser returns an URI which can be stored for later usage. This needs to be done once by the user but can be repeated whenever the destination changes.
37 | There is no way (afaik) to generate a default URI by code to the e.g. downloads folder to omit usage of the browser. If anybody out there knows a way....
38 |
39 | To call the methods in platform code from the shared project the successor of the Dependency Service is used. See both SafService.cs in the shared project and the platform project.
40 |
41 | Here you can find some infos about that here:
42 |
43 | https://blog.taranissoftware.com/platform-specific-code-using-partial-classes-in-net-maui
44 |
45 | https://www.davidbritch.com/search?q=dependencyservice
46 |
47 | A Maui built in way to access (only reading) external files is the FilePicker in Maui. No SAF is needed (only Permissions.StorageRead). See my example FilePickerTest
48 |
--------------------------------------------------------------------------------
/FilePickerTest/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.IO;
3 |
4 | namespace FilePickerTest;
5 |
6 | public partial class MainPage : ContentPage
7 | {
8 |
9 | public MainPage()
10 | {
11 | InitializeComponent();
12 | }
13 |
14 | private async void btnFilePicker_Clicked(object sender, EventArgs e)
15 | {
16 |
17 | // FilePicker needs Permissions.StorageRead
18 | PermissionStatus status = await Permissions.RequestAsync();
19 |
20 | //var customFileType = new FilePickerFileType(
21 | // new Dictionary>
22 | // {
23 | // //{ DevicePlatform.iOS, new[] { "public.my.comic.extension" } }, // UTType values
24 | // { DevicePlatform.Android, new[] { "text/plain", "image/png", "application/vnd.ms-excel" } }, // MIME type
25 | // //{ DevicePlatform.WinUI, new[] { ".cbr", ".cbz" } }, // file extension
26 | // //{ DevicePlatform.Tizen, new[] { "*/*" } },
27 | // //{ DevicePlatform.macOS, new[] { "cbr", "cbz" } }, // UTType values
28 | // });
29 |
30 | //PickOptions options = new()
31 | //{
32 | // PickerTitle = "Please select a file",
33 | // FileTypes = customFileType,
34 | //};
35 |
36 |
37 | var result = await FilePicker.Default.PickAsync(default); // options);
38 | var destpath = Path.Combine(FileSystem.Current.AppDataDirectory, result.FileName);
39 |
40 | var stream = await result.OpenReadAsync();
41 |
42 | // uncomment and set a breakpoint to see what's on the slab
43 | // var x = System.IO.Directory.GetFiles(FileSystem.Current.AppDataDirectory);
44 |
45 | File.Delete(destpath);
46 |
47 | if (!File.Exists(destpath))
48 | {
49 | using (var binaryReader = new BinaryReader(stream))
50 | {
51 | var allBytes = binaryReader.ReadBytes((int)stream.Length);
52 | using (var binaryWriter = new BinaryWriter(new FileStream(destpath, FileMode.Create)))
53 | {
54 | binaryWriter.Write(allBytes);
55 | }
56 | }
57 | }
58 | else
59 | {
60 | Debug.Print(result.FileName + " already saved on device");
61 | }
62 |
63 | // uncomment and set a breakpoint to see what's on the slab
64 | //var y = System.IO.Directory.GetFiles(FileSystem.Current.AppDataDirectory);
65 |
66 | }
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/FilePickerTest/FilePickerTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0-android;net7.0-ios;net7.0-maccatalyst
5 | $(TargetFrameworks);net7.0-windows10.0.19041.0
6 |
7 |
8 | Exe
9 | FilePickerTest
10 | true
11 | true
12 | enable
13 |
14 |
15 | FilePickerTest
16 |
17 |
18 | com.companyname.filepickertest
19 | a5048ac7-425e-4c3c-bcfe-26ee7ef37b5c
20 |
21 |
22 | 1.0
23 | 1
24 |
25 | 11.0
26 | 13.1
27 | 21.0
28 | 10.0.17763.0
29 | 10.0.17763.0
30 | 6.5
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/SafMaui/SafMaui.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0-android;net7.0-ios;net7.0-maccatalyst
5 | $(TargetFrameworks);net7.0-windows10.0.19041.0
6 |
7 |
8 | Exe
9 | SafMaui
10 | true
11 | true
12 | enable
13 |
14 |
15 | SafMaui
16 |
17 |
18 | com.companyname.safmaui
19 | 754cde3e-a349-4db7-ba41-274f36224d34
20 |
21 |
22 | 1.0
23 | 1
24 |
25 | 11.0
26 | 13.1
27 | 21.0
28 | 10.0.17763.0
29 | 10.0.17763.0
30 | 6.5
31 |
32 |
33 |
34 | false
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/SafMaui/Platforms/Android/Service/SafService.cs:
--------------------------------------------------------------------------------
1 | using Android.OS;
2 | using PortableStorage.Droid;
3 | using File = System.IO.File;
4 | using Debug = System.Diagnostics.Debug;
5 |
6 | // SafService.cs Android Platform
7 |
8 | namespace SafMaui
9 | {
10 | public partial class SafService
11 | {
12 | public static Uri StorageUri
13 | {
14 | get
15 | { var Value = Preferences.Get("StorageUri", null);
16 | return Value != null ? new Uri(Value) : null;
17 | }
18 | set => Preferences.Set("StorageUri", value.ToString());
19 | }
20 |
21 | public partial void ShowUriBrowser()
22 | {
23 | try
24 | {
25 | if (Build.VERSION.SdkInt >= BuildVersionCodes.N)
26 | SafStorageHelper.BrowserFolder(MainActivity.Instance, MainActivity.BROWSE_REQUEST_CODE); // >= API Level 24
27 | }
28 | catch (Exception e)
29 | {
30 | Debug.WriteLine(e);
31 | }
32 | }
33 |
34 | public partial void CopyToExternalStorage(string intPath, string fname)
35 | {
36 | if (Build.VERSION.SdkInt >= BuildVersionCodes.N) // >= API Level 24
37 | {
38 | try
39 | {
40 | // Falls es noch keine Uri gibt
41 | if (StorageUri == null) SafStorageHelper.BrowserFolder(MainActivity.Instance, MainActivity.BROWSE_REQUEST_CODE);
42 |
43 | var sourcepath = Path.Combine(intPath, fname);
44 |
45 | if (File.Exists(sourcepath))
46 | {
47 | var stream = File.Open(sourcepath, FileMode.Open);
48 | var sr = new BinaryReader(stream);
49 | var allBytes = sr.ReadBytes((int)stream.Length);
50 |
51 | var externalStorage = SafStorgeProvider.CreateStorage(MainActivity.Instance, StorageUri);
52 | externalStorage.WriteAllBytes(fname, allBytes);
53 | }
54 | }
55 | catch (Exception e)
56 | {
57 | Debug.WriteLine(e);
58 | }
59 | }
60 | }
61 |
62 |
63 |
64 | public partial void CopyFromExternalStorage(string intPath, string fname)
65 | {
66 | if (Build.VERSION.SdkInt >= BuildVersionCodes.N) // >= API Level 24
67 | {
68 | try
69 | {
70 | if (StorageUri == null) SafStorageHelper.BrowserFolder(MainActivity.Instance, MainActivity.BROWSE_REQUEST_CODE);
71 |
72 | var externalStorage = SafStorgeProvider.CreateStorage(MainActivity.Instance, StorageUri);
73 | var allBytes = externalStorage.ReadAllBytes(fname);
74 |
75 | var destpath = Path.Combine(intPath, fname);
76 | using (var stream = File.Open(destpath, FileMode.Create))
77 | {
78 | using (var sr = new BinaryWriter(stream))
79 | {
80 | sr.Write(allBytes);
81 | }
82 | }
83 | }
84 | catch (Exception e)
85 | {
86 | Debug.WriteLine(e);
87 | }
88 | }
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/SafMaui/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using File = System.IO.File;
3 |
4 | namespace SafMaui;
5 | public partial class MainPage : ContentPage
6 | {
7 | public MainPage()
8 | {
9 | InitializeComponent();
10 | }
11 |
12 |
13 | private void btnBrowse_Clicked(object sender, EventArgs e)
14 | {
15 | #if ANDROID
16 | SafService service = new SafService();
17 | service.ShowUriBrowser();
18 | #endif
19 | }
20 |
21 | private void btnCopyToExternalStorage_Clicked(object sender, EventArgs e)
22 | {
23 | #if ANDROID
24 | string fileName = "AboutAssets.txt";
25 | String path = System.IO.Path.Combine(FileSystem.Current.AppDataDirectory, fileName);
26 |
27 | //File.Delete(path);
28 | //Example: If the file does not exist in the Internal Storage, get it from the Bundle-Resources
29 | if (!File.Exists(path)) CopyFileFromAppBundle(FileSystem.Current.AppDataDirectory, fileName);
30 | //var y = System.IO.Directory.GetFiles(FileSystem.Current.AppDataDirectory);
31 |
32 | SafService service = new SafService();
33 | service.CopyToExternalStorage(FileSystem.Current.AppDataDirectory, fileName);
34 | #endif
35 | }
36 |
37 | private async void btnCopyFromExternalStorage_Clicked(object sender, EventArgs e)
38 | {
39 | #if ANDROID
40 | var picked = await PickAndShow(default);
41 |
42 | if (picked != null)
43 | {
44 | string targetFileName = picked.FileName;
45 | string targetPath = FileSystem.Current.AppDataDirectory;
46 | File.Delete(System.IO.Path.Combine(targetPath, targetFileName));
47 | SafService service = new SafService();
48 | service.CopyFromExternalStorage(FileSystem.Current.AppDataDirectory, targetFileName);
49 | //var x = File.Exists(System.IO.Path.Combine(targetPath, targetFileName));
50 | }
51 | #endif
52 | }
53 |
54 | // Copy a (binary) file from the app bundle (Resources/Raw) to destPath
55 | public async Task CopyFileFromAppBundle(string destPath, string targetFileName)
56 | {
57 | var destpath = Path.Combine(destPath, targetFileName);
58 | using Stream fileStream = await FileSystem.Current.OpenAppPackageFileAsync(targetFileName);
59 |
60 | //var x = System.IO.Directory.GetFiles(FileSystem.Current.AppDataDirectory);
61 |
62 | File.Delete(destpath);
63 |
64 | if (!File.Exists(destpath))
65 | {
66 | using (var binaryReader = new BinaryReader(fileStream))
67 | {
68 | var allBytes = binaryReader.ReadBytes((int)fileStream.Length);
69 | using (var binaryWriter = new BinaryWriter(new FileStream(destpath, FileMode.Create)))
70 | {
71 | binaryWriter.Write(allBytes);
72 | }
73 |
74 | //using (var binaryWriter = new BinaryWriter(new FileStream(destpath, FileMode.Create)))
75 | //{
76 | // byte[] buffer = new byte[2048];
77 | // int length = 0;
78 | // while ((length = binaryReader.Read(buffer, 0, buffer.Length)) > 0)
79 | // {
80 | // binaryWriter.Write(buffer, 0, length);
81 | // }
82 | //}
83 | }
84 |
85 | //var y = System.IO.Directory.GetFiles(FileSystem.Current.AppDataDirectory);
86 | }
87 | else
88 | {
89 | Debug.Print(destpath + " already saved on device");
90 | }
91 | }
92 |
93 |
94 | public async Task PickAndShow(PickOptions options)
95 | {
96 | try
97 | {
98 | var result = await FilePicker.Default.PickAsync(options);
99 | //if (result != null)
100 | //{
101 | // if (result.FileName.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) ||
102 | // result.FileName.EndsWith("png", StringComparison.OrdinalIgnoreCase))
103 | // {
104 | // using var stream = await result.OpenReadAsync();
105 | // var image = ImageSource.FromStream(() => stream);
106 | // }
107 | //}
108 |
109 | return result;
110 | }
111 | catch (Exception e)
112 | {
113 | Console.WriteLine(e);
114 | }
115 | return null;
116 | }
117 |
118 | //private async void btnPickAndShow_Clicked(object sender, EventArgs e)
119 | //{
120 | // await PickAndShow(default);
121 |
122 | //}
123 |
124 | }
125 |
126 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Oo]ut/
33 | [Ll]og/
34 | [Ll]ogs/
35 |
36 | # Visual Studio 2015/2017 cache/options directory
37 | .vs/
38 | # Uncomment if you have tasks that create the project's static files in wwwroot
39 | #wwwroot/
40 |
41 | # Visual Studio 2017 auto generated files
42 | Generated\ Files/
43 |
44 | # MSTest test Results
45 | [Tt]est[Rr]esult*/
46 | [Bb]uild[Ll]og.*
47 |
48 | # NUnit
49 | *.VisualState.xml
50 | TestResult.xml
51 | nunit-*.xml
52 |
53 | # Build Results of an ATL Project
54 | [Dd]ebugPS/
55 | [Rr]eleasePS/
56 | dlldata.c
57 |
58 | # Benchmark Results
59 | BenchmarkDotNet.Artifacts/
60 |
61 | # .NET Core
62 | project.lock.json
63 | project.fragment.lock.json
64 | artifacts/
65 |
66 | # ASP.NET Scaffolding
67 | ScaffoldingReadMe.txt
68 |
69 | # StyleCop
70 | StyleCopReport.xml
71 |
72 | # Files built by Visual Studio
73 | *_i.c
74 | *_p.c
75 | *_h.h
76 | *.ilk
77 | *.meta
78 | *.obj
79 | *.iobj
80 | *.pch
81 | *.pdb
82 | *.ipdb
83 | *.pgc
84 | *.pgd
85 | *.rsp
86 | *.sbr
87 | *.tlb
88 | *.tli
89 | *.tlh
90 | *.tmp
91 | *.tmp_proj
92 | *_wpftmp.csproj
93 | *.log
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio LightSwitch build output
298 | **/*.HTMLClient/GeneratedArtifacts
299 | **/*.DesktopClient/GeneratedArtifacts
300 | **/*.DesktopClient/ModelManifest.xml
301 | **/*.Server/GeneratedArtifacts
302 | **/*.Server/ModelManifest.xml
303 | _Pvt_Extensions
304 |
305 | # Paket dependency manager
306 | .paket/paket.exe
307 | paket-files/
308 |
309 | # FAKE - F# Make
310 | .fake/
311 |
312 | # CodeRush personal settings
313 | .cr/personal
314 |
315 | # Python Tools for Visual Studio (PTVS)
316 | __pycache__/
317 | *.pyc
318 |
319 | # Cake - Uncomment if you are using it
320 | # tools/**
321 | # !tools/packages.config
322 |
323 | # Tabs Studio
324 | *.tss
325 |
326 | # Telerik's JustMock configuration file
327 | *.jmconfig
328 |
329 | # BizTalk build output
330 | *.btp.cs
331 | *.btm.cs
332 | *.odx.cs
333 | *.xsd.cs
334 |
335 | # OpenCover UI analysis results
336 | OpenCover/
337 |
338 | # Azure Stream Analytics local run output
339 | ASALocalRun/
340 |
341 | # MSBuild Binary and Structured Log
342 | *.binlog
343 |
344 | # NVidia Nsight GPU debugger configuration file
345 | *.nvuser
346 |
347 | # MFractors (Xamarin productivity tool) working folder
348 | .mfractor/
349 |
350 | # Local History for Visual Studio
351 | .localhistory/
352 |
353 | # BeatPulse healthcheck temp database
354 | healthchecksdb
355 |
356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
357 | MigrationBackup/
358 |
359 | # Ionide (cross platform F# VS Code tools) working folder
360 | .ionide/
361 |
362 | # Fody - auto-generated XML schema
363 | FodyWeavers.xsd
--------------------------------------------------------------------------------
/SafMaui/Resources/Images/dotnet_bot.svg:
--------------------------------------------------------------------------------
1 |
94 |
--------------------------------------------------------------------------------
/FilePickerTest/Resources/Images/dotnet_bot.svg:
--------------------------------------------------------------------------------
1 |
94 |
--------------------------------------------------------------------------------
/SafMaui/Resources/Styles/Styles.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
10 |
11 |
15 |
16 |
21 |
22 |
25 |
26 |
49 |
50 |
67 |
68 |
88 |
89 |
110 |
111 |
132 |
133 |
138 |
139 |
159 |
160 |
178 |
179 |
183 |
184 |
206 |
207 |
222 |
223 |
243 |
244 |
247 |
248 |
271 |
272 |
292 |
293 |
299 |
300 |
319 |
320 |
323 |
324 |
352 |
353 |
373 |
374 |
378 |
379 |
391 |
392 |
397 |
398 |
404 |
405 |
406 |
--------------------------------------------------------------------------------
/FilePickerTest/Resources/Styles/Styles.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
10 |
11 |
15 |
16 |
21 |
22 |
25 |
26 |
49 |
50 |
67 |
68 |
88 |
89 |
110 |
111 |
132 |
133 |
138 |
139 |
159 |
160 |
178 |
179 |
183 |
184 |
206 |
207 |
222 |
223 |
243 |
244 |
247 |
248 |
271 |
272 |
292 |
293 |
299 |
300 |
319 |
320 |
323 |
324 |
352 |
353 |
373 |
374 |
378 |
379 |
391 |
392 |
397 |
398 |
404 |
405 |
406 |
--------------------------------------------------------------------------------