PCLStorage
PCLStorage copied to clipboard
/Documents/../Library Path on IOS
I am getting /var/mobile/Containers/Data/Application/22FAAA71-766D-45CD-9349-C16547432F7B/Documents/../Library as my path on IOS. The .. seems to create problems with other parts of the app trying to use the Path.
Why am I getting "/Documents/../Library" instead of just "/Library"? And how can I fix it?
Thanks M
Same for me. Any update on that?
Did you solve it @mike-rowley ?
Me too, what's the right away to use this?
@MKahmen and @FWJay I haven't found an answer at this point. Please let me know if you do find anything.
@mike-rowley I used a Replace as a workaround. Very dirty, but no idea how I could solve this...
FileSystem.Current.LocalStorage.Path.Replace("/../Library", "")
BTW this works (for whatever reason... path still has /../Library in it, but it's able to save the file:
IFolder rootFolder = FileSystem.Current.LocalStorage;
IFolder folder = await rootFolder.CreateFolderAsync("TestFolder", CreationCollisionOption.OpenIfExists);
IFile file = await folder.CreateFileAsync("test.txt", CreationCollisionOption.ReplaceExisting);
await file.WriteAllTextAsync("test-string");
Thanks @MKahmen, I think the Path.Replace was the hack I used to keep things moving but I agree, very dirty. The second post is what I am doing too but having the /../ causes problems trying to use that path anywhere else.
I've used System.IO.Path.GetFullPath() to remove the .. entries in the past, but it's not available in a PCL
I thought about creating a pull request and changing all instances of Path.Combine in the platform specific code to something like:-
System.IO.Path.GetFullPath(System.IO.Path.Combine(currentPath, relativePath))
... but I didn't want to break everything!
Is anyone braver than me???
@MKahmen Just started using this hack today hah. And thank goodness. XD