Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Moving a document from one doc lib to another

  Asked By: Isabel    Date: Mar 04    Category: Sharepoint    Views: 1444

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.

Share: 

 

1 Answer Found

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

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.




Tagged: