SPPropertyBag Type
我们在使用一个site 保存信息的时候,可以使用 SPPropetryBag来很方便的存储!
Code:
SPWeb spWeb = (new SPSite("http://AA.local")).OpenWeb();
SPPropertyBag spProperties = spWeb.Properties;
foreach (DictionaryEntry entry in spProperties)
Console.WriteLine(" {0,-25} {1}", entry.Key, entry.Value);
我们还可以增加一个新的key and value
Code:
private void SetValue(String key, String value, String siteUrl) { SPWeb spWeb = (new SPSite("http://AA.local")).OpenWeb(); SPPropertyBag spProperties = spWeb.Properties; if (spProperties.ContainsKey(key)) { spProperties[key] = Value; } else { spProperties.Add(Key, Value); } spProperties.Update(); }