From 7293716f718f62da7c9ec19c162b816a515a5568 Mon Sep 17 00:00:00 2001 From: William Jockusch Date: Sun, 1 May 2016 16:34:08 +0300 Subject: [PATCH] Use official approved method of getting library folder on iOS. Should be more future proof. --- src/PCLStorage.FileSystem.Desktop/DesktopFileSystem.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/PCLStorage.FileSystem.Desktop/DesktopFileSystem.cs b/src/PCLStorage.FileSystem.Desktop/DesktopFileSystem.cs index efffdc8..013d283 100644 --- a/src/PCLStorage.FileSystem.Desktop/DesktopFileSystem.cs +++ b/src/PCLStorage.FileSystem.Desktop/DesktopFileSystem.cs @@ -25,8 +25,11 @@ public IFolder LocalStorage #if ANDROID var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); #elif IOS - var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - var localAppData = Path.Combine(documents, "..", "Library"); + NSUrl[] urls = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.User); + if (urls == null || urls.Count() == 0) { + throw new Exception("Failed to find the folder; this should never happen."); + } + return urls[0].Path; #else var localAppData = System.Windows.Forms.Application.LocalUserAppDataPath; #endif