Use SHGetKnownFolderPath() instead of ApplicationData class to get LocalAppData path

耗尽温柔 提交于 2020-01-06 06:00:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!