0

I followed below link http://blogs.msdn.com/b/jfrost/archive/2009/11/08/how-to-display-a-sharepoint-dialog-from-ribbon-button-and-get-selected-item-context.aspx?PageIndex=2#comments

and i got upto fetching docs and show in popup,i am trying to move these docs to destination document library,but i didn't get any solution. Can anyone please send process on how to do this?

2 Answers 2

1

You can use below mentioned code to move files from one Document library to another document library programmatically.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace MoveTo
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://serverName:1111/SitePages/Home.aspx"))
            {
                using (SPWeb web = site.RootWeb)
                {
                    SPFileCollection collFile = web.GetFolder("Shared Documents").Files;
                    int count = collFile.Count;
                    while (count != 0)
                    {
                        collFile[count - 1].MoveTo("Destination Library/" + collFile[count - 1].Name, true);
                        count--;
                    }
                }
            }
        }
    }
}

You can user SPQuery to filter files from document library on above mentioned code...

Another method is to create ribbon button & get selected files on that button click event & move them to another document library.

Happy Coding.... :)

2
  • Is my answer correct for your question?. if it is a proper solution for you than Please mark as correct so it will helpful to others as well... Thanks...
    – Hardik
    Commented Jul 22, 2015 at 4:53
  • but i want selectd files only not move to all files in doc lib.
    – chakri
    Commented Jul 22, 2015 at 10:38
1

Using GUI, you can open Explorer View and make simple drag and drop.

enter image description here

4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.