Skip to main content
added 125 characters in body
Source Link
dasarp
  • 374
  • 3
  • 17

The Export-SPWeb command is available for your help

another approach: the below code will move items from from one list another list in one site collec to another list in another site collec.
This can be executed in a console appln.

    SPSecurity.RunWithElevatedPrivileges(delegate()
      {
        using (SPSite srcSite = new SPSite("http://srcSite1"))
        {
          using (SPWeb srcWeb = mrcSite.OpenWeb())
          {
            SPList srcList = srcWeb.Lists["mydoclib"];
            SPListItem item = srcList.GetItemById(id);

            using (SPSite tgtSite = new SPSite("http://tgtSite"))
            {
              using (SPWeb tgtWeb = tgtSite.OpenWeb())
              {
                SPFolder tgtFolder = tgtWeb.Folders["tgtdoclib"];

                tgtWeb.AllowUnsafeUpdates = true;
                tgtFolder.Files.Add(item.File.Name, item.File.OpenBinary(), true);
                tgtFolder.Update();
              }
            }
          }
        }
      });

The Export-SPWeb command is available for your help

another approach:

    SPSecurity.RunWithElevatedPrivileges(delegate()
      {
        using (SPSite srcSite = new SPSite("http://srcSite1"))
        {
          using (SPWeb srcWeb = mrcSite.OpenWeb())
          {
            SPList srcList = srcWeb.Lists["mydoclib"];
            SPListItem item = srcList.GetItemById(id);

            using (SPSite tgtSite = new SPSite("http://tgtSite"))
            {
              using (SPWeb tgtWeb = tgtSite.OpenWeb())
              {
                SPFolder tgtFolder = tgtWeb.Folders["tgtdoclib"];

                tgtWeb.AllowUnsafeUpdates = true;
                tgtFolder.Files.Add(item.File.Name, item.File.OpenBinary(), true);
                tgtFolder.Update();
              }
            }
          }
        }
      });

The Export-SPWeb command is available for your help

another approach: the below code will move items from from one list another list in one site collec to another list in another site collec.
This can be executed in a console appln.

    SPSecurity.RunWithElevatedPrivileges(delegate()
      {
        using (SPSite srcSite = new SPSite("http://srcSite1"))
        {
          using (SPWeb srcWeb = mrcSite.OpenWeb())
          {
            SPList srcList = srcWeb.Lists["mydoclib"];
            SPListItem item = srcList.GetItemById(id);

            using (SPSite tgtSite = new SPSite("http://tgtSite"))
            {
              using (SPWeb tgtWeb = tgtSite.OpenWeb())
              {
                SPFolder tgtFolder = tgtWeb.Folders["tgtdoclib"];

                tgtWeb.AllowUnsafeUpdates = true;
                tgtFolder.Files.Add(item.File.Name, item.File.OpenBinary(), true);
                tgtFolder.Update();
              }
            }
          }
        }
      });

The Export-SPWebExport-SPWeb command is available for your help

http://technet.microsoft.com/en-us/library/ff607895.aspx

another approach:

    SPSecurity.RunWithElevatedPrivileges(delegate()
      {
        using (SPSite srcSite = new SPSite("http://srcSite1"))
        {
          using (SPWeb srcWeb = mrcSite.OpenWeb())
          {
            SPList srcList = srcWeb.Lists["mydoclib"];
            SPListItem item = srcList.GetItemById(id);

            using (SPSite tgtSite = new SPSite("http://tgtSite"))
            {
              using (SPWeb tgtWeb = tgtSite.OpenWeb())
              {
                SPFolder tgtFolder = tgtWeb.Folders["tgtdoclib"];

                tgtWeb.AllowUnsafeUpdates = true;
                tgtFolder.Files.Add(item.File.Name, item.File.OpenBinary(), true);
                tgtFolder.Update();
              }
            }
          }
        }
      });

The Export-SPWeb command is available for your help

http://technet.microsoft.com/en-us/library/ff607895.aspx

another approach:

    SPSecurity.RunWithElevatedPrivileges(delegate()
      {
        using (SPSite srcSite = new SPSite("http://srcSite1"))
        {
          using (SPWeb srcWeb = mrcSite.OpenWeb())
          {
            SPList srcList = srcWeb.Lists["mydoclib"];
            SPListItem item = srcList.GetItemById(id);

            using (SPSite tgtSite = new SPSite("http://tgtSite"))
            {
              using (SPWeb tgtWeb = tgtSite.OpenWeb())
              {
                SPFolder tgtFolder = tgtWeb.Folders["tgtdoclib"];

                tgtWeb.AllowUnsafeUpdates = true;
                tgtFolder.Files.Add(item.File.Name, item.File.OpenBinary(), true);
                tgtFolder.Update();
              }
            }
          }
        }
      });

The Export-SPWeb command is available for your help

another approach:

    SPSecurity.RunWithElevatedPrivileges(delegate()
      {
        using (SPSite srcSite = new SPSite("http://srcSite1"))
        {
          using (SPWeb srcWeb = mrcSite.OpenWeb())
          {
            SPList srcList = srcWeb.Lists["mydoclib"];
            SPListItem item = srcList.GetItemById(id);

            using (SPSite tgtSite = new SPSite("http://tgtSite"))
            {
              using (SPWeb tgtWeb = tgtSite.OpenWeb())
              {
                SPFolder tgtFolder = tgtWeb.Folders["tgtdoclib"];

                tgtWeb.AllowUnsafeUpdates = true;
                tgtFolder.Files.Add(item.File.Name, item.File.OpenBinary(), true);
                tgtFolder.Update();
              }
            }
          }
        }
      });
added 825 characters in body
Source Link
dasarp
  • 374
  • 3
  • 17

The Export-SPWeb command is available for your help

http://technet.microsoft.com/en-us/library/ff607895.aspx

another approach:

    SPSecurity.RunWithElevatedPrivileges(delegate()
      {
        using (SPSite srcSite = new SPSite("http://srcSite1"))
        {
          using (SPWeb srcWeb = mrcSite.OpenWeb())
          {
            SPList srcList = srcWeb.Lists["mydoclib"];
            SPListItem item = srcList.GetItemById(id);

            using (SPSite tgtSite = new SPSite("http://tgtSite"))
            {
              using (SPWeb tgtWeb = tgtSite.OpenWeb())
              {
                SPFolder tgtFolder = tgtWeb.Folders["tgtdoclib"];

                tgtWeb.AllowUnsafeUpdates = true;
                tgtFolder.Files.Add(item.File.Name, item.File.OpenBinary(), true);
                tgtFolder.Update();
              }
            }
          }
        }
      });

The Export-SPWeb command is available for your help

http://technet.microsoft.com/en-us/library/ff607895.aspx

The Export-SPWeb command is available for your help

http://technet.microsoft.com/en-us/library/ff607895.aspx

another approach:

    SPSecurity.RunWithElevatedPrivileges(delegate()
      {
        using (SPSite srcSite = new SPSite("http://srcSite1"))
        {
          using (SPWeb srcWeb = mrcSite.OpenWeb())
          {
            SPList srcList = srcWeb.Lists["mydoclib"];
            SPListItem item = srcList.GetItemById(id);

            using (SPSite tgtSite = new SPSite("http://tgtSite"))
            {
              using (SPWeb tgtWeb = tgtSite.OpenWeb())
              {
                SPFolder tgtFolder = tgtWeb.Folders["tgtdoclib"];

                tgtWeb.AllowUnsafeUpdates = true;
                tgtFolder.Files.Add(item.File.Name, item.File.OpenBinary(), true);
                tgtFolder.Update();
              }
            }
          }
        }
      });
added 25 characters in body
Source Link
dasarp
  • 374
  • 3
  • 17
Loading
Notice added Needs detailed answers by Robert Lindgren
Source Link
dasarp
  • 374
  • 3
  • 17
Loading