Hi,
I have a document library and i have a task list for this document library to assign task to user,this task list have a attached document.so whenever in task list document update so same update should be happen on document library for same document.
I try but it's not work,i used below code for this
stringfilename = item["FileName"].ToString(); // document name
SPFilefile = item.ParentList.ParentWeb.GetFile(item.Attachments.UrlPrefix+ filename); // file path of the task list attachement
byte[] fileToCopy = file.OpenBinary(); // get binary data of the task list file
SPFolderosubFolder = web.GetFolder(item["FolderURL"].ToString()); // get document library url
SPFiledocfile = web.GetFile(item["DocumentUrl"].ToString()); // get the file from the document library
if(docfile.CheckOutType !=SPFile.SPCheckOutType.None)
{
docfile.CheckIn(
"Automaticaly checkout");
}
docfile.CheckOut();
web.AllowUnsafeUpdates =
true;
docfile = osubFolder.Files.Add(filename, fileToCopy,
true);
web.AllowUnsafeUpdates =
false;
docfile.CheckIn(
"Automaticaly checkout");
Sanjeev Tiwari