0

I have moved document from library to folder within the same document library. For that I have used "Update List Item" action. Now I want to move that document from folder to library again.

0

Let consider Folder name TestDoc and here i am coping a file from source folder FolderA(or from any where in the TestDoc library) to destination folder FolderB

see code below.

public override void ItemUpdated(SPItemEventProperties properties)
{
    string strItemProperty = properties.ListTitle.ToString();
    if (strItemProperty == "TestDoc")
    {
    SPListItem sourceItem = properties.ListItem;
    SPFolder dFolder = sourceItem.Web.Folders[sourceItem.Web.Url + "/TestDoc/"];
    SPFile sfile = sourceItem.File;
    Stream fileStream = null;
    if (sfile != null)
    {
        fileStream = sfile.OpenBinaryStream();
        dFolder.Files.Add(sourceItem.Web.Url + "/TestDoc/FolderB/" + sourceItem.File.Name, fileStream);
        fileStream.Close();
    }
    }
base.ItemUpdated(properties);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.