-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefaultFolderProvider.cs
More file actions
79 lines (73 loc) · 2.99 KB
/
DefaultFolderProvider.cs
File metadata and controls
79 lines (73 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Versioning;
using System.Text;
using System.Threading.Tasks;
namespace MauiFileSaver
{
public class DefaultFolderProvider : IDefaultFolderProvider
{
public readonly static string AndroidImageDCIMPath = "DCIM";
public readonly static string AndroidImagePicturesPath = "Pictures";
public readonly static string AndroidVideoDCIMPath = "DCIM";
public readonly static string AndroidVideoPicturesPath = "Pictures";
public readonly static string AndroidVideoMoviesPath = "Movies";
public readonly static string AndroidAudioAlarmsPath = "Alarms";
public readonly static string AndroidAudioAudiobooksPath = "Audiobooks";
public readonly static string AndroidAudioMusicPath = "Music";
public readonly static string AndroidAudioNotificationsPath = "Notifications";
public readonly static string AndroidAudioPodcastsPath = "Podcasts";
[SupportedOSPlatform("android30.0")]
public readonly static string AndroidAudioRingtonesPath = "Ringtones";
public readonly static string AndroidOtherDownloadPath = "Download";
public virtual string GetDefaultFolder(int folderType)
{
#if ANDROID
return GetDefaultFolder(DevicePlatform.Android, folderType);
#elif WINDOWS
return GetDefaultFolder(DevicePlatform.WinUI, folderType);
#else
return GetDefaultFolder(DevicePlatform.iOS, folderType);
#endif
}
protected virtual string GetDefaultFolder(DevicePlatform platform, int folderType)
{
string folder;
SaveFolderType folderEnumType;
try
{
folderEnumType = (SaveFolderType)folderType;
}
catch
{
folderEnumType = SaveFolderType.Other;
}
if (platform == DevicePlatform.Android)
{
folder = folderEnumType switch
{
SaveFolderType.Video => AndroidVideoMoviesPath,
SaveFolderType.Audio => AndroidAudioMusicPath,
SaveFolderType.Image => AndroidImagePicturesPath,
_ => AndroidOtherDownloadPath,
};
}
else if (platform == DevicePlatform.WinUI)
{
folder = folderEnumType switch
{
SaveFolderType.Video => Environment.GetFolderPath(Environment.SpecialFolder.MyVideos),
SaveFolderType.Audio => Environment.GetFolderPath(Environment.SpecialFolder.MyMusic),
SaveFolderType.Image => Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
_ => Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
};
}
else
{
folder = FileSystem.AppDataDirectory;
}
return folder;
}
}
}