Programmatically reading contents of Files inside folders in Document Library and display in to gridview in MOSS 2007
-
Dienstag, 1. Mai 2012 15:47
Hi,
I have multiple folders in SharePoint document library(MOSS 2007), each of the folders contains multiple files. My requirement is to get all files :Title, Name , Modified Date, Modified By and to display in to grid view.I was using CAML query but not able to get the files name inside the folder only folders name are returning as a query result. Please help.
Alle Antworten
-
Dienstag, 1. Mai 2012 16:21
//Try this
<ViewScope='Recursive'> <Query> <Where> ... </Where> <QueryOptions> <ViewAttributes Scope='Recursive' /> </QueryOptions> <RowLimit>100</RowLimit> </Query> </View>
-Sangeetha
-
Montag, 7. Mai 2012 09:30
Hi Ravi,
In you CAML query, you should set
Query.ViewAttributes = "Scope=\"RecursiveAll\"";For example:
using (SPWeb oWebsite = SPContext.Current.Site.AllWebs["Site_Name"]) { SPList oList = oWebsite.Lists["DocLib_Name"]; SPView oView = oList.Views["View_Name"]; SPQuery oQuery = new SPQuery(oView); oQuery.ViewAttributes = "Scope=\"Recursive\""; SPListItemCollection collListItemsAvailable = oList.GetItems(oQuery); foreach (SPListItem oListItemAvailable in collListItemsAvailable) { Response.Write(SPEncode.HtmlEncode(oListItemAvailable["Name"]) + "<BR>"); } }For more information, please refer to:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.viewattributes.aspx
Thanks,
SimonSimon Huang
TechNet Community Support
- Als Antwort vorgeschlagen Christopher ClementEditor Montag, 7. Mai 2012 09:33
- Als Antwort markiert Shimin Huang Freitag, 11. Mai 2012 06:42
-
Montag, 7. Mai 2012 09:49
Hi,
I have come across the same requirement.I blogged it.
Looping all folders and retrieve the file name
You need to put one more foreach loop inside the SPFolder to loop all the files inside.
Murugesa Pandian.,MCTS|App.Devleopment|Configure
- Bearbeitet Murugesa Pandian Montag, 7. Mai 2012 09:51
- Als Antwort markiert Shimin Huang Freitag, 11. Mai 2012 06:42

