我使用以下代码在文档库中创建一个文件夹。该事件被触发并执行到我的代码的最后一行,没有任何问题。但是,该文件夹未在我的文档库中创建或列出。
public override void ItemAdded(SPItemEventProperties properties)
{
base.ItemAdded(properties);
string strDashListRoot = "http://win-hmpjltdbh5q:37642";
using (SPSite site = new SPSite(strDashListRoot))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
SPList spl = web.Lists["client_documents"];
spl.Items.Add("", SPFileSystemObjectType.Folder, "Helllworld");
spl.Update();
web.AllowUnsafeUpdates = false;
}
}
}
你需要
var i = spl.Items.Add("", SPFileSystemObjectType.Folder, "Helllworld");
i.Update();
代替
spl.Items.Add("", SPFileSystemObjectType.Folder, "Helllworld");
spl.Update();
(假设你的Add
通话很好 - 对我来说看起来没问题)
(另外,您确定需要AllowUnsafeUpdates
处理?我没想到当你处于一个ItemAdded
处理程序。)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)