Question

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.

Was it helpful?

Solution

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
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top