Access _layouts files programmaticaly (file not found exception)


  • Hi everyone,

    i'm developping my first WCM site with MOSS 2007.
    Some pages need to access some external xml files.

    To do so, I used a provisioning feature to put these files into the "_layouts" folder.

    But, when i try to access them from C# code, i always get a File not Found exception

    using System;
    using Microsoft.SharePoint;

    namespace AccesFiles
        class FileAccess
             static void Main(string[] args)
                using (SPSite site = new SPSite("http://myserver:1000"))
                    using (SPWeb web = site.RootWeb)
                        SPFolder folder = web.GetFolder("_layouts"); //I already tried SPFolder folder = web.GetFolder("/_layouts"); but didn't work either
                        SPFile file = web.GetFile("_layouts/myfile.xml");

    Can someone tell me where i'm wrong
    Thank you very much

    • Edited by Mike Walsh FIN Wednesday, September 30, 2009 4:51 PM Problem : removed from Title, We know it's a problem as you posted here ...
    Wednesday, September 30, 2009 4:04 PM


All replies