PCLStorage icon indicating copy to clipboard operation
PCLStorage copied to clipboard

No way to create-or-open file from path?

Open BlueRaja opened this issue 10 years ago • 3 comments

There is IFileSystem.GetFileFromPathAsync(), but if the file doesn't exist it returns null - there is no way to have it create the file.

There is IFolder.CreateFileAsync(), which has an option to open the file if it already exists, but in order to call it you need the IFolder first. You could load that using IFileSystem.GetFolderFromPathAsync() if you knew the folder's path, but if you only know the file's path you're out of luck - there is no way to obtain the folder path given the file path (I would expect that to be a method in PortablePath, but no such method exists).

Given how extremely common of a use-case this is, this seems like a huge gap in the API.

BlueRaja avatar Jun 15 '15 08:06 BlueRaja

I'm new with this library, but what's wrong with using System.IO.Path.GetDirectoryName("path_to_file")? It seems to work just fine, for me.

se7ensoft avatar Jan 22 '16 21:01 se7ensoft

It's been a long time since I posted this, but I'm very familiar with System.IO.Path, so I'm certain I would have tried that and it didn't work, for whatever reason.

BlueRaja avatar Jan 22 '16 21:01 BlueRaja

Well, the library is open-source..... Nothing wrong with coding up what you need and then issuing a pull-request, I suppose. I'm considering doing the same thing as the library seems to lack a few things that I would like, as well.

se7ensoft avatar Jan 22 '16 21:01 se7ensoft