Saturday 15 August 2015

c# - Add a document and metadata to a document library without creating 2 versions -


I need to add a file to the program in a program library with a metadata file and an event handler. I am using the following code in the asynchronous "ItemAdded" and "ItemUpdated" event:

  SPFile destFile = web.Files.Add (newUrl, newFile, true); SPListItem destItem; If (destFile.Item! = Null) {destItem = destFile.Item; } And {destItem = list.Items.Add (folder URL, SPFileSystemObjectType.File); } Foreach (Property Entry Property in Dictionary) {destItem.Properties [property.Key.ToString ()] = property.Value; } DestItem.Update ();  

However, each time a file is added, two versions are created, one after the files. Add method and when one is called SPListItem.Update method is there another way to do this where only one version will be created?

Thank you in advance!

Use

  destItem.SystemUpdate (wrong); To avoid creating a new version In place of the update ()  


No comments:

Post a Comment