【问题标题】:VB.net - Openfilepicker does not work in windows mobile 10 appVB.net - Openfilepicker 在 Windows Mobile 10 应用程序中不起作用
【发布时间】:2016-05-05 20:51:15
【问题描述】:

我正在开发 Windows 10 UWP 和这段代码:

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

在我的 Lumia 535 (Windows mobile 10) 上崩溃,没有错误消息(调试和运行时模式)。

出现启动画面但仍然挂起。

在桌面上一切正常。

在包清单声明中,我为文件打开/保存选择器定义了“.txt”扩展名。

该项目具有目标“Windows 10”和版本“Build 10586”。

【问题讨论】:

    标签: vb.net win-universal-app windows-10-mobile


    【解决方案1】:

    这是我快速写下的内容,它应该允许您访问openfilepicker
    它不完整,但它应该会引导您朝着正确的方向前进。

    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
    


    如果您有任何问题,我会尽力帮助您,但是从您的问题所述,这应该绰绰有余。
    快乐编码!

    【讨论】:

    • 我试过了,但没有改变。我有一个奇怪的效果:正如我所说,不是出现 openfilepicker,而是出现启动屏幕,但是如果我单击底部的 Home 按钮,则会出现 openfilepicker。无论如何,在那一点上,无论我选择什么,什么都不做。
    • 当我使用windows phone 模拟器时,它没有问题,可能是你的手机?尝试使用模拟器,看看它是否有效。
    • 可能是。我会尝试使用模拟器。谢谢。
    • 没问题,如果它在windows 10 mobile的模拟器上运行,请备份您的手机数据并重新格式化
    • 我正在准备一台新电脑,因为我的电脑无法运行模拟器。我会通知你....谢谢。
    猜你喜欢
    • 2013-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多