using System.Collections.Concurrent; using System.Collections.Generic; namespace Wabbajack.Common.IO { /// /// A collection of properties to retrieve specific file system paths for the current user. /// public static class KnownFolders { // ---- MEMBERS ------------------------------------------------------------------------------------------------ private static ConcurrentDictionary _knownFolderInstances; // ---- PROPERTIES --------------------------------------------------------------------------------------------- /// /// The per-user Account Pictures folder. Introduced in Windows 8. /// Defaults to "%APPDATA%\Microsoft\Windows\AccountPictures". /// public static KnownFolder AccountPictures => GetInstance(KnownFolderType.AccountPictures); /// /// The per-user Administrative Tools folder. /// Defaults to "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Administrative Tools". /// public static KnownFolder AdminTools => GetInstance(KnownFolderType.AdminTools); /// /// The per-user app desktop folder, used internally by .NET applications to perform cross-platform app /// functionality. Introduced in Windows 10. /// Defaults to "%LOCALAPPDATA%\Desktop". /// public static KnownFolder AppDataDesktop => GetInstance(KnownFolderType.AppDataDesktop); /// /// The per-user app documents folder, used internally by .NET applications to perform cross-platform app /// functionality. Introduced in Windows 10. /// Defaults to "%LOCALAPPDATA%\Documents". /// public static KnownFolder AppDataDocuments => GetInstance(KnownFolderType.AppDataDocuments); /// /// The per-user app favorites folder, used internally by .NET applications to perform cross-platform app /// functionality. Introduced in Windows 10. /// Defaults to "%LOCALAPPDATA%\Favorites". /// public static KnownFolder AppDataFavorites => GetInstance(KnownFolderType.AppDataFavorites); /// /// The per-user app program data folder, used internally by .NET applications to perform cross-platform app /// functionality. Introduced in Windows 10. /// Defaults to "%LOCALAPPDATA%\ProgramData". /// public static KnownFolder AppDataProgramData => GetInstance(KnownFolderType.AppDataProgramData); /// /// The per-user Application Shortcuts folder. Introduced in Windows 8. /// Defaults to "%LOCALAPPDATA%\Microsoft\Windows\Application Shortcuts". /// public static KnownFolder ApplicationShortcuts => GetInstance(KnownFolderType.ApplicationShortcuts); /// /// The per-user Camera Roll folder. Introduced in Windows 8.1. /// Defaults to ".%USERPROFILE%\Pictures\Camera Roll". /// public static KnownFolder CameraRoll => GetInstance(KnownFolderType.CameraRoll); /// /// The per-user Temporary Burn Folder. /// Defaults to "%LOCALAPPDATA%\Microsoft\Windows\Burn\Burn". /// public static KnownFolder CDBurning => GetInstance(KnownFolderType.CDBurning); /// /// The common Administrative Tools folder. /// Defaults to "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Administrative Tools". /// public static KnownFolder CommonAdminTools => GetInstance(KnownFolderType.CommonAdminTools); /// /// The common OEM Links folder. /// Defaults to "%ALLUSERSPROFILE%\OEM Links". /// public static KnownFolder CommonOemLinks => GetInstance(KnownFolderType.CommonOemLinks); /// /// The common Programs folder. /// Defaults to "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs". /// public static KnownFolder CommonPrograms => GetInstance(KnownFolderType.CommonPrograms); /// /// The common Start Menu folder. /// Defaults to "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu". /// public static KnownFolder CommonStartMenu => GetInstance(KnownFolderType.CommonStartMenu); /// /// The common Startup folder. /// Defaults to "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\StartUp". /// public static KnownFolder CommonStartup => GetInstance(KnownFolderType.CommonStartup); /// /// The common Templates folder. /// Defaults to "%ALLUSERSPROFILE%\Microsoft\Windows\Templates". /// public static KnownFolder CommonTemplates => GetInstance(KnownFolderType.CommonTemplates); /// /// The per-user Contacts folder. Introduced in Windows Vista. /// Defaults to "%USERPROFILE%\Contacts". /// public static KnownFolder Contacts => GetInstance(KnownFolderType.Contacts); /// /// The per-user Cookies folder. /// Defaults to "%APPDATA%\Microsoft\Windows\Cookies". /// public static KnownFolder Cookies => GetInstance(KnownFolderType.Cookies); /// /// The per-user Desktop folder. /// Defaults to "%USERPROFILE%\Desktop". /// public static KnownFolder Desktop => GetInstance(KnownFolderType.Desktop); /// /// The common DeviceMetadataStore folder. Introduced in Windows 7. /// Defaults to "%ALLUSERSPROFILE%\Microsoft\Windows\DeviceMetadataStore". /// public static KnownFolder DeviceMetadataStore => GetInstance(KnownFolderType.DeviceMetadataStore); /// /// The per-user Documents folder. /// Defaults to "%USERPROFILE%\Documents". /// public static KnownFolder Documents => GetInstance(KnownFolderType.Documents); /// /// The per-user Documents library. Introduced in Windows 7. /// Defaults to "%APPDATA%\Microsoft\Windows\Libraries\Documents.library-ms". /// public static KnownFolder DocumentsLibrary => GetInstance(KnownFolderType.DocumentsLibrary); /// /// The per-user localized Documents folder. /// Defaults to "%USERPROFILE%\Documents". /// public static KnownFolder DocumentsLocalized => GetInstance(KnownFolderType.DocumentsLocalized); /// /// The per-user Downloads folder. /// Defaults to "%USERPROFILE%\Downloads". /// public static KnownFolder Downloads => GetInstance(KnownFolderType.Downloads); /// /// The per-user localized Downloads folder. /// Defaults to "%USERPROFILE%\Downloads". /// public static KnownFolder DownloadsLocalized => GetInstance(KnownFolderType.DownloadsLocalized); /// /// The per-user Favorites folder. /// Defaults to "%USERPROFILE%\Favorites". /// public static KnownFolder Favorites => GetInstance(KnownFolderType.Favorites); /// /// The fixed Fonts folder. /// Points to "%WINDIR%\Fonts". /// public static KnownFolder Fonts => GetInstance(KnownFolderType.Fonts); /// /// The per-user GameExplorer folder. Introduced in Windows Vista. /// Defaults to "%LOCALAPPDATA%\Microsoft\Windows\GameExplorer". /// public static KnownFolder GameTasks => GetInstance(KnownFolderType.GameTasks); /// /// The per-user History folder. /// Defaults to "%LOCALAPPDATA%\Microsoft\Windows\History". /// public static KnownFolder History => GetInstance(KnownFolderType.History); /// /// The per-user ImplicitAppShortcuts folder. Introduced in Windows 7. /// Defaults to "%APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\ImplicitAppShortcuts". /// public static KnownFolder ImplicitAppShortcuts => GetInstance(KnownFolderType.ImplicitAppShortcuts); /// /// The per-user Temporary Internet Files folder. /// Defaults to "%LOCALAPPDATA%\Microsoft\Windows\Temporary Internet Files". /// public static KnownFolder InternetCache => GetInstance(KnownFolderType.InternetCache); /// /// The per-user Libraries folder. Introduced in Windows 7. /// Defaults to "%APPDATA%\Microsoft\Windows\Libraries". /// public static KnownFolder Libraries => GetInstance(KnownFolderType.Libraries); /// /// The per-user Links folder. /// Defaults to "%USERPROFILE%\Links". /// public static KnownFolder Links => GetInstance(KnownFolderType.Links); /// /// The per-user Local folder. /// Defaults to "%LOCALAPPDATA%" ("%USERPROFILE%\AppData\Local")". /// public static KnownFolder LocalAppData => GetInstance(KnownFolderType.LocalAppData); /// /// The per-user LocalLow folder. /// Defaults to "%USERPROFILE%\AppData\LocalLow". /// public static KnownFolder LocalAppDataLow => GetInstance(KnownFolderType.LocalAppDataLow); /// /// The fixed LocalizedResourcesDir folder. /// Points to "%WINDIR%\resources\0409" (code page). /// public static KnownFolder LocalizedResourcesDir => GetInstance(KnownFolderType.LocalizedResourcesDir); /// /// The per-user Music folder. /// Defaults to "%USERPROFILE%\Music". /// public static KnownFolder Music => GetInstance(KnownFolderType.Music); /// /// The per-user Music library. Introduced in Windows 7. /// Defaults to "%APPDATA%\Microsoft\Windows\Libraries\Music.library-ms". /// public static KnownFolder MusicLibrary => GetInstance(KnownFolderType.MusicLibrary); /// /// The per-user localized Music folder. /// Defaults to "%USERPROFILE%\Music". /// public static KnownFolder MusicLocalized => GetInstance(KnownFolderType.MusicLocalized); /// /// The per-user Network Shortcuts folder. /// Defaults to "%APPDATA%\Microsoft\Windows\Network Shortcuts". /// public static KnownFolder NetHood => GetInstance(KnownFolderType.NetHood); /// /// The per-user 3D Objects folder. Introduced in Windows 10. /// Defaults to "%USERPROFILE%\3D Objects". /// public static KnownFolder Objects3D => GetInstance(KnownFolderType.Objects3D); /// /// The per-user Original Images folder. Introduced in Windows Vista. /// Defaults to "%LOCALAPPDATA%\Microsoft\Windows Photo Gallery\Original Images". /// public static KnownFolder OriginalImages => GetInstance(KnownFolderType.OriginalImages); /// /// The per-user Slide Shows folder. Introduced in Windows Vista. /// Defaults to "%USERPROFILE%\Pictures\Slide Shows". /// public static KnownFolder PhotoAlbums => GetInstance(KnownFolderType.PhotoAlbums); /// /// The per-user Pictures folder. /// Defaults to "%USERPROFILE%\Pictures". /// public static KnownFolder Pictures => GetInstance(KnownFolderType.Pictures); /// /// The per-user Pictures library. Introduced in Windows 7. /// Defaults to "%APPDATA%\Microsoft\Windows\Libraries\Pictures.library-ms". /// public static KnownFolder PicturesLibrary => GetInstance(KnownFolderType.PicturesLibrary); /// /// The per-user localized Pictures folder. /// Defaults to "%USERPROFILE%\Pictures". /// public static KnownFolder PicturesLocalized => GetInstance(KnownFolderType.PicturesLocalized); /// /// The per-user Playlists folder. /// Defaults to "%USERPROFILE%\Music\Playlists". /// public static KnownFolder Playlists => GetInstance(KnownFolderType.Playlists); /// /// The per-user Printer Shortcuts folder. /// Defaults to "%APPDATA%\Microsoft\Windows\Printer Shortcuts". /// public static KnownFolder PrintHood => GetInstance(KnownFolderType.PrintHood); /// /// The fixed user profile folder. /// Defaults to "%USERPROFILE%" ("%SYSTEMDRIVE%\USERS\%USERNAME%")". /// public static KnownFolder Profile => GetInstance(KnownFolderType.Profile); /// /// The fixed ProgramData folder. /// Points to "%ALLUSERSPROFILE%" ("%PROGRAMDATA%", "%SYSTEMDRIVE%\ProgramData"). /// public static KnownFolder ProgramData => GetInstance(KnownFolderType.ProgramData); /// /// The fixed Program Files folder. /// This is the same as the known folder in 32-bit applications or the /// known folder in 64-bit applications. /// Points to %SYSTEMDRIVE%\Program Files on a 32-bit operating system or in 64-bit applications on a 64-bit /// operating system and to %SYSTEMDRIVE%\Program Files (x86) in 32-bit applications on a 64-bit operating /// system. /// public static KnownFolder ProgramFiles => GetInstance(KnownFolderType.ProgramFiles); /// /// The fixed Program Files folder (64-bit forced). /// This known folder is unsupported in 32-bit applications. /// Points to %SYSTEMDRIVE%\Program Files. /// public static KnownFolder ProgramFilesX64 => GetInstance(KnownFolderType.ProgramFilesX64); /// /// The fixed Program Files folder (32-bit forced). /// This is the same as the known folder in 32-bit applications. /// Points to "%SYSTEMDRIVE%\Program Files" on a 32-bit operating system and to /// "%SYSTEMDRIVE%\Program Files (x86)" on a 64-bit operating system. /// public static KnownFolder ProgramFilesX86 => GetInstance(KnownFolderType.ProgramFilesX86); /// /// The fixed Common Files folder. /// This is the same as the known folder in 32-bit applications or the /// known folder in 64-bit applications. /// Points to" %PROGRAMFILES%\Common Files" on a 32-bit operating system or in 64-bit applications on /// a 64-bit operating system and to "%PROGRAMFILES(X86)%\Common Files" in 32-bit applications on a /// 64-bit operating system. /// public static KnownFolder ProgramFilesCommon => GetInstance(KnownFolderType.ProgramFilesCommon); /// /// The fixed Common Files folder (64-bit forced). /// This known folder is unsupported in 32-bit applications. /// Points to "%PROGRAMFILES%\Common Files". /// public static KnownFolder ProgramFilesCommonX64 => GetInstance(KnownFolderType.ProgramFilesCommonX64); /// /// The fixed Common Files folder (32-bit forced). /// This is the same as the known folder in 32-bit applications. /// Points to "%PROGRAMFILES%\Common Files" on a 32-bit operating system and to /// "%PROGRAMFILES(X86)%\Common Files" on a 64-bit operating system. /// public static KnownFolder ProgramFilesCommonX86 => GetInstance(KnownFolderType.ProgramFilesCommonX86); /// /// The per-user Programs folder. /// Defaults to "%APPDATA%\Microsoft\Windows\Start Menu\Programs". /// public static KnownFolder Programs => GetInstance(KnownFolderType.Programs); /// /// The fixed Public folder. Introduced in Windows Vista. /// Defaults to "%PUBLIC%" ("%SYSTEMDRIVE%\Users\Public)". /// public static KnownFolder Public => GetInstance(KnownFolderType.Public); /// /// The common Public Desktop folder. /// Defaults to "%PUBLIC%\Desktop". /// public static KnownFolder PublicDesktop => GetInstance(KnownFolderType.PublicDesktop); /// /// The common Public Documents folder. /// Defaults to "%PUBLIC%\Documents". /// public static KnownFolder PublicDocuments => GetInstance(KnownFolderType.PublicDocuments); /// /// The common Public Downloads folder. Introduced in Windows Vista. /// Defaults to "%PUBLIC%\Downloads". /// public static KnownFolder PublicDownloads => GetInstance(KnownFolderType.PublicDownloads); /// /// The common GameExplorer folder. Introduced in Windows Vista. /// Defaults to "%ALLUSERSPROFILE%\Microsoft\Windows\GameExplorer". /// public static KnownFolder PublicGameTasks => GetInstance(KnownFolderType.PublicGameTasks); /// /// The common Libraries folder. Introduced in Windows 7. /// Defaults to "%ALLUSERSPROFILE%\Microsoft\Windows\Libraries". /// public static KnownFolder PublicLibraries => GetInstance(KnownFolderType.PublicLibraries); /// /// The common Public Music folder. /// Defaults to "%PUBLIC%\Music". /// public static KnownFolder PublicMusic => GetInstance(KnownFolderType.PublicMusic); /// /// The common Public Pictures folder. /// Defaults to "%PUBLIC%\Pictures". /// public static KnownFolder PublicPictures => GetInstance(KnownFolderType.PublicPictures); /// /// The common Ringtones folder. Introduced in Windows 7. /// Defaults to "%ALLUSERSPROFILE%\Microsoft\Windows\Ringtones". /// public static KnownFolder PublicRingtones => GetInstance(KnownFolderType.PublicRingtones); /// /// The common Public Account Pictures folder. Introduced in Windows 8. /// Defaults to "%PUBLIC%\AccountPictures". /// public static KnownFolder PublicUserTiles => GetInstance(KnownFolderType.PublicUserTiles); /// /// The common Public Videos folder. /// Defaults to "%PUBLIC%\Videos". /// public static KnownFolder PublicVideos => GetInstance(KnownFolderType.PublicVideos); /// /// The per-user Quick Launch folder. /// Defaults to "%APPDATA%\Microsoft\Internet Explorer\Quick Launch". /// public static KnownFolder QuickLaunch => GetInstance(KnownFolderType.QuickLaunch); /// /// The per-user Recent Items folder. /// Defaults to "%APPDATA%\Microsoft\Windows\Recent". /// public static KnownFolder Recent => GetInstance(KnownFolderType.Recent); /// /// The common Recorded TV library. Introduced in Windows 7. /// Defaults to "%PUBLIC%\RecordedTV.library-ms". /// public static KnownFolder RecordedTVLibrary => GetInstance(KnownFolderType.RecordedTVLibrary); /// /// The fixed Resources folder. /// Points to "%WINDIR%\Resources". /// public static KnownFolder ResourceDir => GetInstance(KnownFolderType.ResourceDir); /// /// The per-user Ringtones folder. Introduced in Windows 7. /// Defaults to "%LOCALAPPDATA%\Microsoft\Windows\Ringtones". /// public static KnownFolder Ringtones => GetInstance(KnownFolderType.Ringtones); /// /// The per-user Roaming folder. /// Defaults to "%APPDATA%" ("%USERPROFILE%\AppData\Roaming"). /// public static KnownFolder RoamingAppData => GetInstance(KnownFolderType.RoamingAppData); /// /// The per-user RoamedTileImages folder. Introduced in Windows 8. /// Defaults to "%LOCALAPPDATA%\Microsoft\Windows\RoamedTileImages". /// public static KnownFolder RoamedTileImages => GetInstance(KnownFolderType.RoamedTileImages); /// /// The per-user RoamingTiles folder. Introduced in Windows 8. /// Defaults to "%LOCALAPPDATA%\Microsoft\Windows\RoamingTiles". /// public static KnownFolder RoamingTiles => GetInstance(KnownFolderType.RoamingTiles); /// /// The common Sample Music folder. /// Defaults to "%PUBLIC%\Music\Sample Music". /// public static KnownFolder SampleMusic => GetInstance(KnownFolderType.SampleMusic); /// /// The common Sample Pictures folder. /// Defaults to "%PUBLIC%\Pictures\Sample Pictures". /// public static KnownFolder SamplePictures => GetInstance(KnownFolderType.SamplePictures); /// /// The common Sample Playlists folder. Introduced in Windows Vista. /// Defaults to "%PUBLIC%\Music\Sample Playlists". /// public static KnownFolder SamplePlaylists => GetInstance(KnownFolderType.SamplePlaylists); /// /// The common Sample Videos folder. /// Defaults to "%PUBLIC%\Videos\Sample Videos". /// public static KnownFolder SampleVideos => GetInstance(KnownFolderType.SampleVideos); /// /// The per-user Saved Games folder. Introduced in Windows Vista. /// Defaults to "%USERPROFILE%\Saved Games". /// public static KnownFolder SavedGames => GetInstance(KnownFolderType.SavedGames); /// /// The per-user Searches folder. /// Defaults to "%USERPROFILE%\Searches". /// public static KnownFolder SavedSearches => GetInstance(KnownFolderType.SavedSearches); /// /// The per-user Screenshots folder. Introduced in Windows 8. /// Defaults to "%USERPROFILE%\Pictures\Screenshots". /// public static KnownFolder Screenshots => GetInstance(KnownFolderType.Screenshots); /// /// The per-user History folder. Introduced in Windows 8.1. /// Defaults to "%LOCALAPPDATA%\Microsoft\Windows\ConnectedSearch\History". /// public static KnownFolder SearchHistory => GetInstance(KnownFolderType.SearchHistory); /// /// The per-user Templates folder. Introduced in Windows 8.1. /// Defaults to "%LOCALAPPDATA%\Microsoft\Windows\ConnectedSearch\Templates". /// public static KnownFolder SearchTemplates => GetInstance(KnownFolderType.SearchTemplates); /// /// The per-user SendTo folder. /// Defaults to "%APPDATA%\Microsoft\Windows\SendTo". /// public static KnownFolder SendTo => GetInstance(KnownFolderType.SendTo); /// /// The common Gadgets folder. Introduced in Windows 7. /// Defaults to "%ProgramFiles%\Windows Sidebar\Gadgets". /// public static KnownFolder SidebarDefaultParts => GetInstance(KnownFolderType.SidebarDefaultParts); /// /// The per-user Gadgets folder. Introduced in Windows 7. /// Defaults to "%LOCALAPPDATA%\Microsoft\Windows Sidebar\Gadgets". /// public static KnownFolder SidebarParts => GetInstance(KnownFolderType.SidebarParts); /// /// The per-user OneDrive folder. Introduced in Windows 8.1. /// Defaults to "%USERPROFILE%\OneDrive". /// public static KnownFolder SkyDrive => GetInstance(KnownFolderType.SkyDrive); /// /// The per-user OneDrive Camera Roll folder. Introduced in Windows 8.1. /// Defaults to "%USERPROFILE%\OneDrive\Pictures\Camera Roll". /// public static KnownFolder SkyDriveCameraRoll => GetInstance(KnownFolderType.SkyDriveCameraRoll); /// /// The per-user OneDrive Documents folder. Introduced in Windows 8.1. /// Defaults to "%USERPROFILE%\OneDrive\Documents". /// public static KnownFolder SkyDriveDocuments => GetInstance(KnownFolderType.SkyDriveDocuments); /// /// The per-user OneDrive Pictures folder. Introduced in Windows 8.1. /// Defaults to "%USERPROFILE%\OneDrive\Pictures". /// public static KnownFolder SkyDrivePictures => GetInstance(KnownFolderType.SkyDrivePictures); /// /// The per-user Start Menu folder. /// Defaults to "%APPDATA%\Microsoft\Windows\Start Menu". /// public static KnownFolder StartMenu => GetInstance(KnownFolderType.StartMenu); /// /// The per-user Startup folder. /// Defaults to "%APPDATA%\Microsoft\Windows\Start Menu\Programs\StartUp". /// public static KnownFolder Startup => GetInstance(KnownFolderType.Startup); /// /// The fixed System32 folder. /// This is the same as the known folder in 32-bit applications. /// Points to "%WINDIR%\system32" on 32-bit operating systems or in 64-bit applications on a 64-bit /// operating system and to "%WINDIR%\syswow64" in 32-bit applications on a 64-bit operating system. /// public static KnownFolder System => GetInstance(KnownFolderType.System); /// /// The fixed System32 folder (32-bit forced). /// This is the same as the known folder in 32-bit applications. /// Points to "%WINDIR%\syswow64" in 64-bit applications or in 32-bit applications on a 64-bit /// operating system and to "%WINDIR%\system32" on 32-bit operating systems. /// public static KnownFolder SystemX86 => GetInstance(KnownFolderType.SystemX86); /// /// The per-user Templates folder. /// Defaults to "%APPDATA%\Microsoft\Windows\Templates". /// public static KnownFolder Templates => GetInstance(KnownFolderType.Templates); /// /// The per-user User Pinned folder. Introduced in Windows 7. /// Defaults to "%APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned". /// public static KnownFolder UserPinned => GetInstance(KnownFolderType.UserPinned); /// /// The fixed Users folder. Introduced in Windows Vista. /// Points to "%SYSTEMDRIVE%\Users". /// public static KnownFolder UserProfiles => GetInstance(KnownFolderType.UserProfiles); /// /// The per-user Programs folder. Introduced in Windows 7. /// Defaults to "%LOCALAPPDATA%\Programs.". /// public static KnownFolder UserProgramFiles => GetInstance(KnownFolderType.UserProgramFiles); /// /// The per-user common Programs folder. INtroduced in Windows 7. /// Defaults to "%LOCALAPPDATA%\Programs\Common". /// public static KnownFolder UserProgramFilesCommon => GetInstance(KnownFolderType.UserProgramFilesCommon); /// /// The per-user Videos folder. /// Defaults to "%USERPROFILE%\Videos". /// public static KnownFolder Videos => GetInstance(KnownFolderType.Videos); /// /// The per-user Videos library. Introduced in Windows 7. /// Defaults to "%APPDATA%\Microsoft\Windows\Libraries\Videos.library-ms". /// public static KnownFolder VideosLibrary => GetInstance(KnownFolderType.VideosLibrary); /// /// The per-user localized Videos folder. /// Defaults to "%USERPROFILE%\Videos". /// public static KnownFolder VideosLocalized => GetInstance(KnownFolderType.VideosLocalized); /// /// The fixed Windows folder. /// Points to "%WINDIR%". /// public static KnownFolder Windows => GetInstance(KnownFolderType.Windows); // ---- METHODS (PRIVATE) -------------------------------------------------------------------------------------- private static KnownFolder GetInstance(KnownFolderType type) { // Check if the caching directory exists yet. if (_knownFolderInstances == null) _knownFolderInstances = new ConcurrentDictionary(); // Get a KnownFolder instance out of the cache dictionary or create it when not cached yet. if (!_knownFolderInstances.TryGetValue(type, out KnownFolder knownFolder)) { knownFolder = new KnownFolder(type); if (_knownFolderInstances.TryAdd(type, knownFolder)) return knownFolder; return _knownFolderInstances[type]; } return knownFolder; } } }