I have an interesting (well to me anyways) problem here. I am doing a code based mass upload of documents into a SharePoint library with a twist. The twist is that the file's last modified date needs to be maintained in the item properties after the upload.
The file details are determined from a csv file that contains the path and the metatdata that needs to be attached to the library items as the library is based on a custom content type with metadata fields.
The problem I am having is that the modified date is only being maintained with the last file uploaded. All other files indicate the upload time. I did a little more digging and turned on version control. It turns out that files that I have uploaded are being modified multiple times as they have multiple minor versions applied to them, while the final file being uploaded has only one. For example. I am uploading 6 files to test out the process. The last file that is uploaded is sitting at version .1, the other files range from version .6 to .8 to .12. All files you can see had the correct modified date at the initial setup upon upload, but immediately a change occurred that modified the date and incremented the new modified date.
I have tried an date using the following methods:
item.Update() (when accessing items as a list and not from a file object
None of these updates seem to do what I wish.
Try Using site As SPSite = New SPSite(siteURL) Using Web As SPWeb = site.OpenWeb() Dim itemList As SPList = Web.Lists("DM Import Test") For Each item As SPListItem In itemList.Items If item.Name = importFile.fileName Then item(SPBuiltInFieldId.Modified) = importFile.modifiedDate item.Update() End If Next End Using End Using
importFile is just a custom object with the properties I need.
I also tried building the entry with:
spFile = uploadFolder.Files.Add(Path.GetFileName(importFile.FullPath), fileStream, createdBy, modifiedBy, created, modified)
Where the uploadFolder was an folder object of the libary.
Please let me know if you have come across this and if you happen to have a resolution.