//Call my document library’s listservice webservice Sharepoint_WebService.Lists listService = new Sharepoint_WebService.Lists(); listService.Credentials = new System.Net.NetworkCredential("username", "password"); //get the entire list items from the specified document library XmlNode ndList = listService.GetListItems(accountName, null, null, null, null, null, null); XmlNamespaceManager nsMgr = new XmlNamespaceManager(ndList.OwnerDocument.NameTable); nsMgr.AddNamespace("rs"”, "urn:schemas-microsoft-com:rowset"); nsMgr.AddNamespace("z", "#RowsetSchema"); //if the document library is empty if (ndList != null) { XmlNode dataNode = ndList.SelectSingleNode("rs:data", nsMgr); int itemCount = Convert.ToInt32(dataNode.Attributes.GetNamedItem("ItemCount").Value); if (itemCount == 0) { MessageBox.Show("No file to search"); } else { //get the entire items in the document library foreach (XmlNode row in dataNode.SelectNodes("z:row", nsMgr)) { //if one of the item equals "Group Verification.docx" if ((row.Attributes.GetNamedItem("ows_LinkFilename").Value).ToString() == "Group Verification.docx") { MessageBox.Show("File Found"); } //no verification document has been uploaded else { MessageBox.Show("File not found"); } } } }
Friday, March 4, 2011
Searching for a file/doc in a document library in Sharepoint
Labels:
Sharepoint
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment