CHAPTER 8 DEPLOYING REPORTS
}
catch (SoapException ex)
{
MessageBox.Show(ex.Detail.InnerXml.ToString());
}
}
}
The code starts by getting the full path on the SSRS 2012 server where the user has selected to place
the report from the ssrsFolders TreeView control, strips the word Root off the front of the path, and then
replaces all occurrences of a backslash in the string with the forward slash needed for SSRS 2012.
You then set the options for the openFileDialog control so that it browses by default for files with the
RDL extension and then displays the dialog box to the user. If the user makes a selection, then the file is
opened using a FileStream object and read from the stream into a byte array. That’s because the SSRS
2012 CreateCatalogItem method expects the contents of the RDL file to be passed in as a byte array.
Next, the file name that the user selected is read and used as the title for the report in SSRS 2012.
After you have a title, you have everything necessary to upload the report, which you do by calling the
CreateCatalogItem method with the values you’ve created. You can see at the end of Listing 8-8 where
the necessary code has been added to the complete listing.
Running the Application
Now let’s run the example. Start the project and, when the form displays, enter the name of your report
server in the Server textbox and click Go. Localhost was used in the example; use the name of your server
if it is different. Your form now looks similar to Figure 8-14, with the folders on your SSRS 2012 server
displayed and the Root folder highlighted.