问题
In an desktop-bridge app, I want to find the LocalAppData (or LocalCache) folder of that specific package. I can get the LocalCache folder path with ApplicationData class:
using Windows.Storage;
string appData = ApplicationData.Current.LocalCacheFolder.Path;
Alternatively, if I use SHGetKnownFolderPath function I can also get that same path:
wchar_t* appData;
SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_FORCE_APP_DATA_REDIRECTION, NULL, &appData);
So my question: Is it appropriate to use SHGetKnownFolderPath()
instead of ApplicationData class? Both give same path in UWP environment. Is there any drawback/cons to use the first one?
回答1:
You could call any methods before you convert your desktop app to UWP app. Once you converted it successfully, after that, if you want to extend it, for example: Extend your desktop application with modern UWP components, then, you would have to use UWP APIs.
来源:https://stackoverflow.com/questions/50203270/use-shgetknownfolderpath-instead-of-applicationdata-class-to-get-localappdata