Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8882987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:42:29+00:00 2026-06-14T20:42:29+00:00

I am moving image files from document library of a Web site to a

  • 0

I am moving image files from document library of a Web site to a document library in another Web site. I get the following error @ line SPListItem oListItemDest = oFileDest.Item;

error:
[Microsoft.SharePoint.SPException] = {“The object specified does not belong to a list.”}

Code:

   try
   {
      using (SPSite oSiteCollectionSrc = new SPSite("http://dev:32223/"))
      {
                SPWeb oWebsiteSrc = oSiteCollectionSrc.AllWebs["en/people"];
                SPList oListSrc = oWebsiteSrc.Lists["Images"];  

                SPListItemCollection collListItemsSrc = oListSrc.Items;

                foreach (SPListItem oListItemSrc in collListItemsSrc)
                {
                    SPFile oFileSrc = oListItemSrc.File;
                    Stream srcStream = oFileSrc.OpenBinaryStream();

                    using (SPSite oSiteCollectionDest = new SPSite("http://www.devmysites.com/"))
                    {
                        SPWeb oWebsiteDest = oSiteCollectionDest.OpenWeb("en/people");
                        SPList oListDest = oWebsiteDest.Lists["Images"];

                        SPFileCollection collFilesDest = oListDest.RootFolder.Files;

                        try
                        {

                            SPFile oFileDest = collFilesDest.Add(oListDest + @"/" + oFileSrc.Name, srcStream, true);
                            SPListItem oListItemDest = oFileDest.Item;
                            oListItemDest["Created"] = oFileDest.TimeCreated;
                            oListItemDest["Modified"] = oFileDest.TimeLastModified;
                            oListItemDest.Update();
                        }
                        catch(Exception es1)
                        {
                            Console.WriteLine("# Exception:#");
                            Console.WriteLine(es1.Message);
                        }

                        oWebsiteDest.Dispose();
                    }
                }
                oWebsiteSrc.Dispose();
            }
        }
        catch (Exception es)
        {
            Console.WriteLine("# Exception:#");
            Console.WriteLine(es.Message);
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:42:30+00:00Added an answer on June 14, 2026 at 8:42 pm

    I have also had to copy documents between sharepoint lists, the code that I used to do it is in the answer to this question: SharePoint 2010: Copy documents between lists

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When moving a site from a staging environment to a production environment, .png image
I'm moving from FCK editor to CK editor 3.6.3 and the site has a
list item is not moving from one list box to another . I tried
I'm working on moving a large number of documents from an older document management
I got the below code from @DanS at this link how-to-display-a-map-still-image-file-with-a-moving-current-location onCurrentPosition(Location current){ double
In a web browser, I am trying to pan an image from left to
Afrter moving site from RedHAT/CloudLinux/ Apache 2.2 to to Windows 2008 R* / IIS7
I have been manipulating image files after uploading in the usual way like moving
I have an application where I can have an image moving towards the eye.
I'm trying to build an image gallery with description when moving over the image.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.