Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Problem with Copying a Document to another Site's Document Library

  Asked By: Elvin    Date: Feb 03    Category: Sharepoint    Views: 1423

I want to copy a document to another site's document library. I
hav written the code as given below. BUT IT IS NOT WORKING. Please
look at my code and tell me if its right or wrong.
void IListEventSink.OnEvent(Microsoft.SharePoint.SPListEvent
listEvent)
{
WindowsImpersonationContext wic = CreateIdentity
("mssps2k3admin", "myorg", "password").Impersonate();
//To Add the Document to Another Site's History Library
if ((listEvent.Type == SPListEventType.Insert)||
(listEvent.Type == SPListEventType.Update)||
(listEvent.Type == SPListEventType.CheckIn))
{
SPWeb site = listEvent.Site.OpenWeb();
SPFile file = site.GetFile(listEvent.UrlAfter);
if (file.Item[file.Item.Fields
["MyWorkFlow"].Title].ToString().Equals("Submit"))
{
file.Item[file.Item.Fields["MyWorkFlow"].Title]
="WaitingForReview";
file.Item.Update();
byte [] binFile = file.OpenBinary();
SPWeb destWeb = new SPSite
("http://myportal.myorg.org/personal/otheremp").OpenWeb();
SPFolder destFolder = destWeb.GetFolder("DOCLIB3");
destFolder.Files.Add(file.Name, binFile, true);
}
}
wic.Undo();
}

Share: 

 

No Answers Found. Be the First, To Post Answer.

 

Related Topics:



Tagged:          

 

Related Post