tags:

views:

47

answers:

1

Hi,

I am trying to access sharepoint list and error:

""/SiteDirectory/_layouts/viewlists.aspx" contains reserved name. Please try another one."

Code view :

private void button1_Click(object sender, EventArgs e)

{

        //String parameters to enable site and list access
        const string siteUrl = "http://Myserver/";

        //const string siteName = "SiteDirectory/testlists/";
        const string siteName = "/SiteDirectory/_layouts/testlists.aspx";
        const string sourceFileName = "Shared%20Documents/TestUpload.doc";

        OfficialFileResult result;
        string fileResult;

        //Freeze UI
        Cursor = Cursors.WaitCursor;
        button1.Enabled = false;

        //Return a site collection using the SPSite constructor providing the site URL
        SPSite siteCollection = new SPSite(siteUrl);

        //Return the target web site based on site name
        SPWeb site = siteCollection.AllWebs[siteName];  
        // **Getting Error at this Line**

        //Access file from within site based on path
        SPFile file = site.GetFile(sourceFileName);

        result = file.SendToOfficialFile(out fileResult);

        //UI clean-up
        label1.Text = "Records Hold Status: " + result;
        Cursor = Cursors.Default;
        button1.Enabled = true; 

}

Please help.

Regards, Jene

A: 

SiteName isn't "/SiteDirectory/_layouts/testlists.aspx"! SiteName should be.. SiteDirectory in this case, I think. Try it yourself - enumerate through all the webs, and look at their names. These are indexes to the AllWebs[] dictionary!

Yossarian