Search This Blog

Showing posts with label sharepoint list item copy. Show all posts
Showing posts with label sharepoint list item copy. Show all posts

Sunday, November 13, 2011

Access, Copy, and Move Files


To retrieve files and folders from a Web site, use the GetFile or GetFolder method of the SPWeb class.
You can use the GetFolder method of the SPWeb class to return a specified folder. Then you can access individual files in the folder. After instantiating an SPWeb object (for example, as oWebsite), use SPFolder oFolder = oWebsite.GetFolder("Shared Documents") (in Microsoft Visual Basic, use Dim oFolder As SPFolder = oWebsite.GetFolder("Shared Documents")) to return the Shared Documents folder for the site.
using (SPWeb oWebsite = new SPSite("http://Server/sites/SiteCollection").OpenWeb())
{
    string folderUrl = "/Shared Documents/MySubFolder";
    SPFolder oFolder = oWebsite.GetFolder(folderUrl);
    SPFileCollection collFile = oFolder.Files;

    foreach (SPFile oFile in collFile)
    {
        Label1.Text += "<BR>Url: " + oFile.Url.ToString() + " Size: " + oFile.Length.ToString();
    } 
}

Featured Posts

Unlock Hidden Windows Startup and Shutdown Details : How to Enable Verbose Startup and Shutdown Messages in Windows 11

WINDOWS TROUBLESHOOTING · FULL GUIDE Unlock Hidden Windows Startup and Shutdown Details Enable Verbose Status...