PCLStorage icon indicating copy to clipboard operation
PCLStorage copied to clipboard

/Documents/../Library Path on IOS

Open mike-rowley opened this issue 8 years ago • 8 comments

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

mike-rowley avatar Aug 30 '16 14:08 mike-rowley

Same for me. Any update on that?

Did you solve it @mike-rowley ?

MKahmen avatar Sep 16 '16 21:09 MKahmen

Me too, what's the right away to use this?

jaykannan avatar Oct 14 '16 09:10 jaykannan

@MKahmen and @FWJay I haven't found an answer at this point. Please let me know if you do find anything.

mike-rowley avatar Oct 14 '16 22:10 mike-rowley

@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", "")

MKahmen avatar Oct 17 '16 10:10 MKahmen

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");

MKahmen avatar Oct 17 '16 12:10 MKahmen

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.

mike-rowley avatar Oct 18 '16 16:10 mike-rowley

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???

JasonBro avatar Dec 13 '16 20:12 JasonBro

@MKahmen Just started using this hack today hah. And thank goodness. XD

leenephi avatar Feb 07 '17 15:02 leenephi