dsplaisted / PCLStorage

PCL Storage - Portable Storage APIs
Microsoft Public License
305 stars 95 forks source link

/Documents/../Library Path on IOS #49

Open mike-rowley opened 8 years ago

mike-rowley commented 8 years ago

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

MKahmen commented 8 years ago

Same for me. Any update on that?

Did you solve it @mike-rowley ?

jaykannan commented 7 years ago

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

mike-rowley commented 7 years ago

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

MKahmen commented 7 years ago

@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 commented 7 years ago

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");
mike-rowley commented 7 years ago

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.

JasonBro commented 7 years ago

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

leenephi commented 7 years ago

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