Clear Cached Files from Client Automatically
-
Thursday, September 13, 2012 9:39 PM
We have some sensitive files on the SP site and want to make sure that when a user checks it out and makes changes and saves it back to server - the user cannot save it locally and any cached temporary files on the user's machine are deleted.
This site is just a list of data files - there is minimum background coding involved.
Can someone help with how to do this? Thanks much.
- Edited by tinadusa Thursday, September 13, 2012 9:40 PM Additional info
All Replies
-
Friday, September 14, 2012 5:40 AMModerator
Hi,
I ma not sure but i think event handler can help to delete file from temp folder. You can create ItemUpdated event handler which will fire when you updated file in document library and will deplete files from temp location.
You can use .NET class to get temp location:
string tempFilename = System.IO.Path.GetTempFileName();
Here is full code to delete file which need to execute through event receiver:
public void WriteFile(string filePath, StoredFile file, bool tempLocation) { // [snip..] try fileStream.Write(data, 0, data.Length); fileStream.Flush(); fileStream.Close(); if (tempLocation) { Process p = System.Diagnostics.Process.Start(@strPath); p.WaitForExit(); File.Delete(strPath); } } finally { if (fileStream != null) fileStream.Dispose(); } }Check this thread for more info: http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/d84a1fed-5e70-4d21-a3a8-54a075c8be5e
Let us know your comment
Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
- Proposed As Answer by Ed Price - MSFTMicrosoft Employee Wednesday, October 17, 2012 12:53 AM
- Unproposed As Answer by Ed Price - MSFTMicrosoft Employee Wednesday, October 17, 2012 12:53 AM
-
Friday, September 14, 2012 10:51 AM
Thanks Hemendra, but like I said this site is just a repository of files - doc, xls, ppt, etc. - there is no background code. The site is just a list.
Additionally, the file I think is cached even if opened for reading and I want to delete that so I cannot use itemupdated event handler. Maybe there is one for file opened?
Would I have to put this code on the site and each of the pages using SP Designer?
Thanks.
- Edited by tinadusa Friday, September 14, 2012 10:53 AM more info
-
Friday, September 14, 2012 11:19 AMModerator
>Would I have to put this code on the site and each of the pages using SP Designer?
This code will not work in designer it will require visual studio..
As per my memory, if you don't check out the doc then it does not save in cache. Can you verify this.
Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
- Proposed As Answer by Ed Price - MSFTMicrosoft Employee Wednesday, October 17, 2012 12:53 AM
- Marked As Answer by Yaoyao ChenMicrosoft Contingent Staff, Moderator Wednesday, October 17, 2012 1:05 AM
-
Friday, September 14, 2012 4:34 PM
Thanks Hemendra, you are right. It does not seem to cache if a file is not checked out or opened read only.
But I doubt I can add the code that you mentioned earlier. is there a config param?
Thanks. -
Wednesday, September 19, 2012 6:31 PM
Hi Hemendra,
So if I have a standard site or list of documents, how would I add this code to that page? The site is under a larger corporate SP site and server.
Thanks,
Tina
-
Thursday, September 20, 2012 5:16 AMModerator
Hi,
You may create custom feature and add this feature in site library. So whenever you open library display page this code will fire and remove the cache.
Just do some googling you will find lots of material for custom feature creation and deployment.
Hope it could help
Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
- Proposed As Answer by Ed Price - MSFTMicrosoft Employee Wednesday, October 17, 2012 12:53 AM
- Marked As Answer by Yaoyao ChenMicrosoft Contingent Staff, Moderator Wednesday, October 17, 2012 1:04 AM

