Sharepoint Forum

 
Home » Forum » Sharepoint       Ask a questionRSS Feeds

Moving a document from one doc lib to another

  Asked By: Isabel Sparks         Date: Mar 04, 2010      Category: Sharepoint      Views: 439
 

I need to move a document from one 1 document Library to another and
remove it from the former one.

Is there any direct RPC or web service avilable for the same.

Also other than using DLL's, is there a webservice available for
deleting documents from a document Library.

Tagged:                

 

1 Answer Found

 
Answer #1       Answered By: Rose Silva          Answered On: Mar 04, 2010       

SPFile class has CopyTo( ) using which you can copy a document  from one library
to another.
Example:
SPSite site = SPControl.GetContextSite(Context);
SPWeb web  = site.AllWebs["Site_Name"];

SPFileCollection files = web.GetFolder("Source_DocLibrary").Files;

for (int i=0; i<files.Count; i++)
{
if (files[i].CheckInComment == "Complete")
{
files[i].CopyTo("Destination_DocLibrary/" + files[i].Name);
}
}

 
Didn't find what you were looking for? Find more on Moving a document from one doc lib to another Or get search suggestion and latest updates.


Your Answer
  • Answer should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].