I am working on UWP, I want to store paths somewhere, and I found ApplicationData.LocalSettings can do it.
But I got an error when I stored the share folder path through it because of the \ and I don't know why. Is there any good solution to it?
Here is the code,just simple:
var path = @"\\192.168.1.1\test";
ApplicationData.Current.LocalSettings.Values.Keys.Contains<string>(path);
ApplicationData.Current.LocalSettings.Values[path] = xxx;
The contains function and add function also throw COMException
I tried your code. LocalSettings cannot use path as a key since it contains the \ symbol.
For example,
String path = @"&&192.168.1.1&test"; // I replaced every \ with &
ApplicationData.Current.LocalSettings.Values[path] = "your string";
will save your string correctly.
UWP ApplicationData LocalSettings
We could reproduce this problem, it looks "\" char is not support but not "", for this scenario, the better way is using "path" string as key to replace path value-key. And I will report this problem.
ApplicationData.Current.LocalSettings.Values["path"] = xxxx;
Or replace the header \\ with empty.
var path = @"192.168.1.1\test";