views:

846

answers:

1

Hi,

I have added a menu item in ECB of document of document library. On click of that menu i want to copy that document to my application. For this purpose i need to create a temporary file of the document on the same machine where SharePoint server is installed. Now the problem is that where should i create the temporary file. One solution is TEMP folder of current user(who has logged in sharepoint). But in sharepoint, Users from Active Directory can also login but temp folder is only available for users on that machine. In short requirement is to create temporary file in a folder where every user (users on that machine as well as AD users) have rights to create and delete file.

Does sharepoint recommend any specific location for this purpose?

+1  A: 

SharePoint uses .NET, so you should use .NET features for this:

string tempFilename = System.IO.Path.GetTempFileName();

The service account's notion of TEMP will be used, not the logged-in user's.

-Oisin

x0n
Hi OisinThanx for your answer.>>The service account's notion of TEMP will be used, not the logged-in user's<<As per my understanding you are trying to say that if I use function GetTempFileName(), Temporary file would not be created using logged in user's credential but using service account's credential.What do you mean by "service account's notion of TEMP"
Anoop
Yes, that's what I mean - the service account's %TEMP% var should be used, not the currently logged in user's. Test it, I'm pretty sure.
x0n
And if it is running in the context of an impersonated "normal" user you can always revert to the Application Pool's identity to run that code. This of course assumes that your code has the right privs to revert back to the App Pool Identity and it assumes that the App Pool identity has Temp directory privs.
Mark Mascolino