March 16, 2014

SharePoint read csv or xml file from wsp / solution of _layouts file.

SharePoint how to read any csv or xml file in webpart using C# code.

Usually we doesn’t required this scenario, but in some cases you want to keep any config data or aby xml data apart from typical SPList you have to create a Config or default setting file that cabn be access by your C# code,

Finally you want to get file that you have mapped in _layouts so using StreamReader / Stream or File.Open(); it needs file’s absolute path and if you are in SharePoint wsp so that makes you to follow approach like below,

In file path string pass below way

SharePoint – C# get xml file from _layouts
Read external file in SharePoint C#


Praveen Pandit