Tuesday, September 23, 2008

Programatically Accessing Report Folders & their Report in C#

This post is for accessing Report folder names and correspoinding reports(.rdl files) in Reporting Serbices via C# code.

1. Add a web Reference of the url http:///ReportServer/ReportService.asmx
Name it as ReportingService2005 (my convention)
2. import
using ReportingService2005;
3.

ReportingService2005.ReportingService rs;

rs = new ReportingService2005.ReportingService();
rs.Credentials = new System.Net.NetworkCredential("", "", "");
CatalogItem[] items = rs.ListChildren("/", false);
foreach (CatalogItem item in items)
{
CatalogItem[] items_rdl = rs.ListChildren("/"+item.Name, false);
foreach (CatalogItem i in items_rdl){
i.Name.ToString()
}
}

Note :
First foreach would display all report foldernames.
Second foreach would display all rdl files in first step forders.

No comments: