Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Programaticaly how to update document in sharepoint 2010

$
0
0

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


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>