0

我想知道如何为我选择的 USB 设备保存我的用户配置。每当我重新启动设备时,它将按照我之前选择的方式加载。建议保存在本地还是USB存储中?

此应用笔记存储和检索适用于提到的应用数据类型的设置和其他应用数据是否适用于 USB 适配器?

选定的设备

更新:

当我从列表框中选择 USB 适配器时,我相应地设置了相应的选定设备。

        private void audioCaptureList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            recordPlayer.AudioDevice = captureDeviceList[audioCaptureList.SelectedIndex];
        }

        private void audioRenderList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            mediaPlayer.AudioDevice = renderDeviceList[audioRenderList.SelectedIndex];

        }
4

1 回答 1

0

您的设置可以保存为本地应用数据。即使您重新启动设备,这些数据也不会改变。但请注意: 应用数据的生命周期与应用的生命周期相关。如果应用程序被删除,所有应用程序数据将因此丢失

您可以像这样存储和检索本地应用程序数据:

    Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

    private void StoreButton_Click(object sender, RoutedEventArgs e)
    {
        var selection = ConnectDevices.SelectedItems;
        var entry = (DeviceListEntry)selection[0];
        var device = entry.DeviceInformation;

        localSettings.Values["SelectedUsbDeviceId"] =  device.Id;
        localSettings.Values["SelectedUsbDeviceName"] = device.Name;
    }

    private void RetrieveButton_Click(object sender, RoutedEventArgs e)
    {
        Object deviceId = localSettings.Values["SelectedUsbDeviceId"];
        Object deviceName = localSettings.Values["SelectedUsbDeviceName"];
    }
于 2017-10-27T07:44:20.650 回答