-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FileopenPicker (UWP) throws error when PickSingleFileAsync() called #23
Comments
You can add file type filters like so: var singleFilePick = new FileOpenPicker();
singleFilePick.FileTypeFilter.Add(".jpg");
var pickedFile = await singleFilePick.PickSingleFileAsync(); Let me know if this solves your issue. |
Duh, I’m being dense… thank you. End of a long day... |
James, I am trying to open a file on UWP, but keep getting error stating file does not exists. I think the source is line#62 here: StorageFile.cs I would expect SystemIO.File.Exists() to work on Dorid/iOS, but not UWP (always returns false due to difference in sec vs. desktop API on windows). I am interested in using several of your libs with Xamarin.Forms to support multiplatform, but I suspect you have not designed for use on UWP. |
I have proven that the issue is with System.IO.File.Exists() on UWP. It no work like expected =( . Sad that .NetStandard provides an API that doesn't behave... but that's why we have the PCL mess we have … anyway, that's a different topic. If you were to replace line #62 in StorageFile.cs with something like: I could then provide a different impl for UWP. Is supect there is similar code in StorageFolder.cs (line 65) Edit: I just saw that the StorageFile class is sealed.... makes a solution harder. |
@jasells I will take a look into this. It has previously been working but as you've mentioned, changes in .NET Standard may have broken this and as you've pointed out, this is because File.Exists doesn't work if the file in UWP is outside of the scope of the application's storage location. |
The only way I've been able to accomplish the File.Exists fuctionality (even in a pure UWP app) is to get the file's parent folder object, and the call GetItemAsync() and check the result for null. I did this as a work-around for now in my Xamarin code: `public async Task<System.IO.Stream> OpenFileForRead(XPlat.Storage.IStorageFile file)
This is basically what I did using Xamarin's Dependency service to provide the UWP plugin code above, and then I used an extension method in my portable code to add it back to Xplat.Storage.IStorageFile and just not using OpenReadAsync() provided. It might be more a function of the target/min UWP version, not .NetStandard, if you say it has been working? I am targeting min of 1709 (SDK v. 16299). |
Have you looked into this yet? I have found several similar issues. It seems that the System.IO.File.Exists API is not behaving as expected... I am basically having to work around anything that checks for the existance of the file, some of them could be avoided as I think they are unnecessary checks. But I get why you did it if .Exists worked previously. The native errors are a little vague sometimes. At this point though, I am going to have to re-impl almost everything to make it work on UWP. If you are not working on them yet, I may pull a fork and start playing with it. I would like to build onto what you have with a XPlat.Storage.Portable namespace that has Xamarin plugin impl built in. I think it would be a separate package that depends on yours, so as to not force Xamarin dependencies on anything currently using these libs. Open to suggestions there. |
I think the appropriate thing to do here is close this issue, and open a new one with a more appropriate title/focus. |
"WinRT information: The FileTypeFilters property must have at least one file type filter specified."
There is no way to set the filter... it is read only, and not virtual.
FileOpenPicker.cs
Am I missing some other initialization step?
The text was updated successfully, but these errors were encountered: