关闭应用程序后,如何在 windows 移动应用程序中保存(或)保留全局登录凭据 10 天?

How to save (or) keep Global login credentials for 10 days in windows mobile application, after closing the application?

目前正在处理全局 variables.am 在我的 windows 手机中将登录详细信息保存在全局变量 app.xaml.cs 中 application.I 只是想长期保留登录详细信息即使在注销或关闭后的时间 application.i 也想长时间存储数据。可能吗 ?谁能给我解决问题的想法。

//app.xaml.cs
public string username { get; set; }
public string password { get; set; }

//navigate to next page
this.Frame.Navigate(typeof(new page name), null);

是的,您可以简单地在 App 文件夹中创建一个本地文件并在其中保存数据,即使使用下面的 UWP 类 关闭 App -

// Create sample file; replace if exists.

Windows.Storage.StorageFolder storageFolder =
    Windows.Storage.ApplicationData.Current.LocalFolder;
Windows.Storage.StorageFile sampleFile =
    await storageFolder.CreateFileAsync("sample.txt",
        Windows.Storage.CreationCollisionOption.ReplaceExisting);

await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "Your data");

您可以随时使用 DeleteAsync 方法简单地删除文件。

您也可以在您的应用中使用 SQLLiteDb 来存储数据。

您还可以在使用 Credential Locker 保存凭据时使用 Credential Locker to securely store and retrieve user credentials. Using the Credential Locker API, you can store the username and password for your user and easily retrieve them and log the user in automatically the next time they open your app. Then, you could set a time stamp in localsettings

当您从 Credential Locker 检索凭据时,您可以先检查时间戳是否已逾期 10 天。如果它已过期,您可以将其从 Credential Locker 中删除并要求用户再次输入他们的用户名和密码。

这里有一个 Credential Locker 样本供您参考。