Can't read file in ItemAdding event receiver
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
精彩评论