ApplicationData.GetForPackageFamily(String) 方法

定义

获取当前用户的指定包系列 ApplicationData 实例。

public:
 static ApplicationData ^ GetForPackageFamily(Platform::String ^ packageFamilyName);
 static ApplicationData GetForPackageFamily(winrt::hstring const& packageFamilyName);
public static ApplicationData GetForPackageFamily(string packageFamilyName);
function getForPackageFamily(packageFamilyName)
Public Shared Function GetForPackageFamily (packageFamilyName As String) As ApplicationData

参数

packageFamilyName
String

Platform::String

winrt::hstring

返回

示例

以下示例演示如何将数据保存到特定包系列的应用程序数据存储:

void SaveData(string data)
{
    string packageFamilyName = "Fabrikam.Contoso_1234567890abc";
    var applicationData = ApplicationData.GetForPackageFamily(packageFamilyName);
    var filename = Path.Combine(applicationData.LocalPath, "applicationdata.dat");
    File.WriteAllText(filename, data, System.Text.UTF8Encoding);
}

注解

请注意,此方法等效于 Windows.Storage.ApplicationDataManager.CreateForPackageFamily()

适用于

另请参阅