使用 SHGetKnownFolderPath() 而不是 ApplicationData 类来获取 LocalAppData 路径 [英] Use SHGetKnownFolderPath() instead of ApplicationData class to get LocalAppData path

查看:16
本文介绍了使用 SHGetKnownFolderPath() 而不是 ApplicationData 类来获取 LocalAppData 路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在桌面桥接应用程序中,我想找到该特定包的 LocalAppData(或 LocalCache)文件夹.我可以使用 ApplicationData class 获取 LocalCache 文件夹路径:

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;

或者,如果我使用 SHGetKnownFolderPath 函数我也可以得到相同的路径:

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);

所以我的问题是:使用 SHGetKnownFolderPath() 而不是 ApplicationData 类是否合适?两者在 UWP 环境中都给出了相同的路径.使用第一个有什么缺点/缺点吗?

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?

推荐答案

在将桌面应用程序转换为 UWP 应用程序之前,您可以调用任何方法.成功转换后,之后如果要扩展它,例如:使用现代 UWP 组件扩展您的桌面应用程序,然后,您将不得不使用 UWP API.

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.

这篇关于使用 SHGetKnownFolderPath() 而不是 ApplicationData 类来获取 LocalAppData 路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆