代码之家  ›  专栏  ›  技术社区  ›  Daniele Milani

配置UWP本机Messagging应用程序

  •  2
  • Daniele Milani  · 技术社区  · 7 年前


    我想配置一个 UWP App in order to receive messages from an Edge Extension ,并使用一些外部配置来回答这些消息:我尝试使用 Windows Credentials Vault ,但似乎无法访问它 (the UWP App seems running in a SandBox) ,没有Windows凭据库的可见性)。



    达妮埃莱

    1 回复  |  直到 7 年前
        1
  •  0
  •   Daniele Milani    7 年前

    我不知道这是不是最好的选择, but an UWP app can read a file from the local storage .
    因此,在安装完成后,我在本地存储目录(%USERPROFILE%\AppData\local\Packages\\LocalState)中编写了一个配置文件,我可以使用以下代码从UWP应用程序访问它:

    Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
    Windows.Storage.StorageFile configFile = await storageFolder.GetFileAsync("config");
    String configContent = await Windows.Storage.FileIO.ReadTextAsync(configFile);
    //configContent now contains the config info