Sharepoint - How to Access Files / Document Set Programatically
-
viernes, 13 de abril de 2012 5:43
Issue :
I want to be able to poll for the Time Last Modified of some documents, to see if they have changed, then I will copy them to a network area and runs some scripts. IDE VS2010 C#
Under Sharepoint 2010 (new server warming up for roll out) or Sharepoint 2007 (existing server). Having a document set would be useful because there are 3 documents in the set, and if I do this check mid way when the user is checking in documents, then I will not have a set that is atomic. Thus I think I am talking myself into using SP 2010.
Background:
I did a google with “C# how to watch for sharepoint file changes” or “C# how to read sharepoint file time last modified” and came up remarkable short of info. Most was around the FIleWatcher in C# which does not work for a url.
I did find a reference to MS’s code samples at http://code.msdn.microsoft.com/SharePoint-2010-101-Code-da251182/view/SamplePack however nothing seems close except for “SharePoint 2010 Managing Document Sets Programmatically” which doesn’t build.
Request:
- Code samples / URL to help me read the TLM or version of a program set (or individual file)
- Code samples / URL on how to fetch the document set
Hopefully without me needing to do web type programming, i.e. use some API that does the version and file fetch directly.
Documents will be in a document folder
Thanks!!
- Editado Greg B Roberts viernes, 13 de abril de 2012 5:54
Todas las respuestas
-
viernes, 13 de abril de 2012 14:00
Hi Greg,
Couple of things here to start with:
You could achieve the "FileWatcher" functionality using an event receiver on the libraries to detect ItemUpdated. To create an event receiver, see here:
http://msdn.microsoft.com/en-us/library/ee231563.aspx
Second, to access the document set you can use the GetDocumentSet(SPFolder) method of the Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet namespace with the Microsoft.Office.DocumentManagement.dll reference. (http://msdn.microsoft.com/en-us/library/microsoft.office.documentmanagement.documentsets.documentset.getdocumentset.aspx)
Here is a post I found that makes use of this method to make changes to the welcome page of the document set. http://social.msdn.microsoft.com/Forums/br/sharepoint2010general/thread/34fa3673-45e9-4477-9713-b0b6bde35097
You could put all this together and make an event receiver on ItemUpdated, grab the document set, and copy them to the network area as required.
Let me know if you need more specific code than these overviews.
- Propuesto como respuesta Arun Kumar Arora sábado, 14 de abril de 2012 11:51
- Marcado como respuesta Qiao WeiMicrosoft Contingent Staff, Moderator jueves, 19 de abril de 2012 9:36
-
viernes, 13 de abril de 2012 23:05
Thanks Mat
This seems a good start for me to trial
Greg
-
martes, 22 de mayo de 2012 6:08
Followup
The problem with the examples given is finding the complete context on how to make the code work on the client side.
Examples often do not reference the Using statements or references needed to be added to a project.
I tried to get some answers under http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/ad170d4d-2b34-4047-ab06-83a19aaf70c5 but did not get over the line.
regards

