Hi,
I'm able to find the folder availability in share point lists using below code snippet.
try
{
Guid guid = new Guid(listGUID);
SPSite site = new SPSite("http://localhost:8081/");
SPWeb website = site.OpenWeb();
SPList listname = website.Lists[guid];
//Check if the Folder is already available in the list
SPQuery query = new SPQuery();
query.Query = "<Where><And><Eq><FieldRef Name='Title'/><Value Type='Text'>" + "assignmentfolder" + "</Value></Eq><Eq><FieldRef
Name='FSObjType'/><Value Type='Lookup'>1</Value></Eq></And></Where>";
query.ViewAttributes = "Scope=\"RecursiveAll\"";
//Retrieve the items based on Query
SPListItemCollection items = listname.GetItems(query);
//Item count is "0" if the folder does not exist
if (items.Count == 0)
return false;
}
catch (Exception ex) {}
As per the architecture of my project, I need to implement above said code using "GetListItems" web service.
XmlNode query = null;
XmlNode qryOptions = null;
string foldernme = "People";
query = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "<Where><And><Eq><FieldRef Name='Title'/><Value Type='Text'>" + foldernme + "</Value></Eq><Eq><FieldRef Name='FSObjType'/><Value Type='Lookup'>1</Value></Eq></And></Where>");
qryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "<ViewAttributes Scope='RecursiveAll'/>");
XmlNode getFolders = ListWebService.GetListItems(listGUID, null, query, null, null, qryOptions, null);
The web service returning all the folders which are resides in the lists (see below: this is outcome of getfolders.outerXML). Instead of all the folders, I just want to check whether folders are exist or not.
<z:row ows_Attachments="0" ows_LinkTitle="Folder1" ows_MetaInfo="697;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Folder1" ows_ID="697" ows_owshiddenversion="1" ows_UniqueId="697;#{2706A63C-6B49-4578-BD76-4BF076E5A71B}" ows_FSObjType="697;#1" ows_Created_x0020_Date="697;#2013-06-26 02:21:54" ows_Created="2013-06-26 02:21:53" ows_FileLeafRef="697;#Folder1" ows_FileRef="697;#Lists/Configuration/Folder1" />
<z:row ows_Attachments="0" ows_LinkTitle="Folder2" ows_MetaInfo="262;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Folder2" ows_ID="262" ows_owshiddenversion="1" ows_UniqueId="262;#{4A049EBF-25AA-454D-9273-D9EE72FFF30B}" ows_FSObjType="262;#1" ows_Created_x0020_Date="262;#2013-06-26 02:14:41" ows_Created="2013-06-26 02:14:40" ows_FileLeafRef="262;#Folder2" ows_FileRef="262;#Lists/Configuration/Folder2" />
<z:row ows_Attachments="0" ows_LinkTitle="Folder3" ows_MetaInfo="249;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Folder3" ows_ID="249" ows_owshiddenversion="1" ows_UniqueId="249;#{0B38052A-E355-433A-8781-C731BF36CF3B}" ows_FSObjType="249;#1" ows_Created_x0020_Date="249;#2013-06-26 02:10:57" ows_Created="2013-06-26 02:10:57" ows_FileLeafRef="249;#Folder3" ows_FileRef="249;#Lists/Configuration/Folder3" />
<z:row ows_Attachments="0" ows_LinkTitle="Folder4" ows_MetaInfo="1;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Folder4" ows_ID="1" ows_owshiddenversion="1" ows_UniqueId="1;#{8676365D-6B1C-42CF-8EBB-1BF4240F05A8}" ows_FSObjType="1;#1" ows_Created_x0020_Date="1;#2013-06-26 02:10:39" ows_Created="2013-06-26 02:10:38" ows_FileLeafRef="1;#Folder4" ows_FileRef="1;#Lists/Configuration/Folder4" /></rs:data></listitems>
could you please help me on this?
No comments:
Post a Comment