private ArrayList GetNonFolderItems(SPList list) { ArrayList fileList = new ArrayList(list.RootFolder.Files); IComparer compFiles = new SPFilesComparer(); fileList.Sort(compFiles); return(fileList); }
private void AddDocuments(SPFolder folder, XmlDocument doc, XmlNode parentNode) { XmlNode ndView; XmlNode ndCell; if (folder != null) { ndView = doc.CreateNode(XmlNodeType.Element, "row", doc.NamespaceURI); ndCell = doc.CreateNode(XmlNodeType.Element, "cell", doc.NamespaceURI); ndCell.InnerText = "<img align=\"absmiddle\" src=\"/_layouts/images/16fold.gif\"/> <label>" + folder.Name + "</label>"; ndView.AppendChild(ndCell); if (folder.Files.Count > 0) { ArrayList fileList = new ArrayList(folder.Files); IComparer compFiles = new SPFilesComparer(); fileList.Sort(compFiles); for (int i = 0; i < fileList.Count; i++) { SPFile file = (SPFile)(fileList[i]); if (file != null) { XmlNode ndDoc = doc.CreateNode(XmlNodeType.Element, "row", doc.NamespaceURI); XmlNode ndUserdata = doc.CreateNode(XmlNodeType.Element, "userdata", doc.NamespaceURI); XmlAttribute attrName = doc.CreateAttribute("name"); attrName.Value = "ViewTitle"; ndUserdata.Attributes.Append(attrName); ndUserdata.InnerText = file.Item.DisplayName; XmlNode ndUserdata2 = doc.CreateNode(XmlNodeType.Element, "userdata", doc.NamespaceURI); XmlAttribute attrName2 = doc.CreateAttribute("name"); attrName2.Value = "ViewRelativeUrl"; ndUserdata2.Attributes.Append(attrName2); ndUserdata2.InnerText = file.ServerRelativeUrl; ndCell = doc.CreateNode(XmlNodeType.Element, "cell", doc.NamespaceURI); ndCell.InnerText = "<img align=\"absmiddle\" src=\"/_layouts/IMAGES/" + file.IconUrl + "\"/> <a href=\"#\">" + file.Item.DisplayName + "</a>"; ndDoc.AppendChild(ndUserdata); ndDoc.AppendChild(ndUserdata2); ndDoc.AppendChild(ndCell); ndView.AppendChild(ndDoc); } } parentNode.AppendChild(ndView); } if (folder.SubFolders.Count > 0) { foreach (SPFolder subFolder in folder.SubFolders) { AddDocuments(subFolder, doc, ndView); } } } }