I have been working on a PoC in SharePoint, that on an EventReceiver handling items added or updated in Document Libraries, has to copy the file in a temporary folder.

I would want to know, is there a way to know which user will be writing the file in the folder? Because as this might be working on different servers, permissions must be given.

有帮助吗?

解决方案

Use SPSecurity.RunWithElevatedPrivileges for all disk operations because incoming user is unlikely to have permissions to write anything to server's file system.

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    // open/write/close file here. 
    // Avoid touching SPxxxx objects from outside of this delegate
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top