我尝试使用文件路径(只是一个字符串)作为ApplicationDataContainer中的键,但它失败了。有3个不同的问题:
有没有人见过像这样的问题,这是预期的行为吗?我找不到任何文档路径作为键无效的文档,对于我来说MS似乎很奇怪,因为他们知道并将其视为一个随机字符串,并将其视为文件路径。
An unhandled exception of type 'System.Exception' occurred in mscorlib.dll
WinRT information: Error trying to query the application data container item info
Additional information: The specified path is invalid.
示例代码:
var container = ApplicationData.Current.LocalSettings.CreateContainer("SomeContainerName", ApplicationDataCreateDisposition.Always);
if (container.Values.ContainsKey("C:\\Some_Fake_Path") == false) // This will report as true even though the key is not in the container
{
//If you try to run this line it throws an exception that file can not be found even though it is just a key value pair
container.Values.Add("C:\\Some_Fake_Path", "SomeStuffHere");
//This line won't throw, but it won't actually add a key/value pair either
container.Values.Add("C:\\This_Path_Actually_Exists\\SomeFile.txt", "SomeStuffHere");
}