Search code examples
vb.netwin-universal-appwindows-10-mobile

VB.net - Openfilepicker does not work in windows mobile 10 app


I'm developing a Windows 10 UWP and this piece of code :

Dim wopk As FileOpenPicker = New FileOpenPicker
With wopk
 .ViewMode = PickerViewMode.List
 .SuggestedStartLocation = PickerLocationId.DocumentsLibrary
 .FileTypeFilter.Add(".txt")
 dim wfile = Await .PickSingleFileAsync()
End with

crash on my Lumia 535 (Windows mobile 10) without error message (both debug and runtime mode).

Appears the splash screen and still hang.

On desktop everything works fine.

In package manifest Declarations, I defined for File Open/Save Picker the ".txt" extension.

The project has as target "Windows 10" and as version "Build 10586".


Solution

  • here is something that i have quickly written up, it should allow you to access openfilepicker
    It's not complete, however it should lead you in the right direction.

    Imports Windows.Storage.Pickers
    Public NotInheritable Class MainPage
    Inherits Page
    
    Private Async Sub button_Click(sender As Object, e As RoutedEventArgs) Handles button.Click
        Dim openfilepicker = New FileOpenPicker
        openfilepicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary
        openfilepicker.FileTypeFilter.Add(".txt")
        openfilepicker.CommitButtonText = "Open"
    
        Dim Textfile = Await openfilepicker.PickSingleFileAsync()
        If Textfile IsNot Nothing Then
            Dim SelectedTextFile = Await Textfile.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite)
            'Write your code here using SelectedTextFile as the source for the async.
        End If
    
    End Sub
    End Class
    


    If you have any problems i will do my best to help you out, however from what your question has stated, this should be more than enough.
    Happy Coding!