May 05 2017 08:06 AM
When using the Pnp-Powershell Add-PnpFile cmdlet, we can upload a file and alter the Created or Modified field at the same time.
e.g. I can change the Modified field on the uploaded file
PS:> Add-PnPFile -Path .\sample.doc -Folder "Shared Documents" -Values @{Modified="1/1/2016"}
I would like to know are there equivalent code in Pnp-sites-core component?
May 05 2017 08:13 AM
The PowerShell Cmdlet uses the following code:
Microsoft.SharePoint.Client.File file; if (ParameterSetName == "AsFile") { file = folder.UploadFile(FileName, Path, true); } else { file = folder.UploadFile(FileName, Stream, true); } if (Values != null) { var item = file.ListItemAllFields; foreach (var key in Values.Keys) { item[key as string] = Values[key]; } item.Update(); ClientContext.ExecuteQueryRetry(); }
So you could use the same.
May 05 2017 08:16 AM
May 05 2017 08:26 AM
AFAIK, there isn't any.