Find document in Sharepoint -
Find document in Sharepoint -
looking way find document registered in sharepoint. can find document in documet library or list next code.
spsite ospsite = new spsite(_serverurl); spweb ospweb = ospsite.openweb(); splist osplist; splistitemcollection osplistitemcollection; osplist = ospweb.lists["listname"]; splistitem listitem = null; listitem = osplist.getitembyuniqueid(new guid(spguid));
but need iterate trough list if dont know in list document registered or there more efficient way.
if uniqueid info have have create spsitedataquery
retrieve url of document:
spweb web = // ... spsitedataquery q = new spsitedataquery(); q.query = string.format( "<where><eq><fieldref name='uniqueid' /><value type='lookup'>{0}</value></eq></where>", spguid); q.lists = "<lists basetype="1" />"; // restrict document libraries q.rowlimit = 1; // q.webs = "<webs scope='sitecollection' />"; add together broaden search on whole site collection q.viewfields = "<fieldref name='encodedabsurl' />"; datatable tbl = web.getsitedata(q); if (tbl.rows.count == 0) throw new filenotfoundexception(...); homecoming tbl.rows[0]["encodedabsurl"];
then can load spfile
(the document) spweb.getfile(string)
. if need splistitem
can access via spfile.item
.
sharepoint
Comments
Post a Comment