How to Move Files within SharePoint?

March 29, 2016

Blogger Image

Rajapandian R

Module Lead

In SharePoint, files within SharePoint document libraries can be moved to be rearranged or segregated from one folder and moved to different folders. This helps in easy maintenance and reference. There are different options available to move files within SharePoint document libraries. We can see them one by one:

Option 1:

Go to Explorer view, then copy paste the files to a different location.

Sharepoint Document Libraries

Here we can move multiple files. But Meta data like - created by and created time will be changed.

Option 2:

Click on file --> Send To --> Other Location

SharePoint document libraries

Option 3:

Moving of files can also be done by writing a C# application.
Add Microsoft.SharePoint.dll in your project.


using Microsoft.SharePoint;
    private void button1_Click(object sender, EventArgs e)
    {
        SPSite sourceSite = new SPSite(SourceSiteURL);
        SPWeb sourceWeb = sourceSite.OpenWeb();
        SPSite destSite = new SPSite(DestinationSiteURL);
        SPWeb destWeb = destSite.OpenWeb();

        SPFolder oFolder = sourceWeb.GetFolder(SourceFolderName).SubFolders.Folder;
        SPFolder oDestFolder = destWeb.GetFolder(DestinationFolderName).SubFolders.Folder;

        foreach (SPFile oFile in oFolder.Files)
        {
            string strDestURL = oDestFolder.Url + "/";
            SPFile f = oFile;
            f.MoveTo(strDestURL + f.Name);
        }

        sourceWeb.Dispose();
        sourceSite.Dispose();
        destWeb.Dispose();
        destSite.Dispose();
    }


This option helps in moving multiple files within SharePoint Document Libraries with meta data. The code can be customized depending on which file in SPWeb or subfolder in SPWeb the files need to be moved to.

Join the conversation

What are your thoughts on this blog? Drop us a line below. We’d love to hear from you.

© 2017 Nous Infosystems Pvt. Ltd. All rights reserved.