开发者

Can't read file in ItemAdding event receiver

开发者 https://www.devze.com 2023-03-22 08:16 出处:网络
I try to read file in ItemAdding (SharePoint2010). I use开发者_开发知识库 this code: public override void ItemAdding(SPItemEventProperties properties)

I try to read file in ItemAdding (SharePoint2010). I use开发者_开发知识库 this code:

public override void ItemAdding(SPItemEventProperties properties)
{
 XmlDocument doc = new XmlDocument();
 string file = Path.Combine(properties.WebUrl, properties.AfterUrl);
 doc.Load(file);
}

but program return error in doc.Load(file); - The remote server returned an error: (401) Unauthorized. How to solve this problem?


In which user-context is the code running? does it have enough permissions to that file?

You could try using elevated privileges http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消