locked
how to add a folder to a spweb site RRS feed

  • Question

  • Hi,

    How can I add a folder myFolder to an SPWeb site mysite pls?

    I need to be able after that to access the folder programmatically this way:

    SPFolder myFolder= site.Folders["myFolderName"];

    So, how can I create it in the site in the first place.

    I am asking because i need to dynamically create spfolders and add them in my site.

    Thanks a lot for your help.

    Saturday, January 20, 2007 1:18 AM

Answers

  • Is this what you were looking for?

    using (SPSite site = new SPSite("http://localhost"))
    {

    using (SPWeb web = site.OpenWeb())
    {

    web.Folders.Add("TestFolder");
    web.Update();

    }

    }

    Monday, January 29, 2007 3:27 AM