答案 0 :(得分:1)
我能够通过使用WMI提供程序来获得需要的信息: https://docs.microsoft.com/de-de/previous-versions/windows/desktop/offlinefiles/about-offline-files-wmi-provider
编辑:
别忘了添加对System.Management
的引用。
我想出了以下代码段:
ManagementScope scope = new ManagementScope("\\\\.\\ROOT\\cimv2");
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_OfflineFilesItem");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
var pinInfo = (ManagementBaseObject)m.GetPropertyValue("PinInfo");
if (pinInfo != null)
{
if ((bool)pinInfo.GetPropertyValue("Pinned"))
{
//the file or folder is set to "always available offline"
var itemPath = m["ItemPath"]
}
}
}