What I'm trying to do is upload a file with metadata without creating a new version using the client object model.
I already have this code:
byte[] bytes = System.IO.File.ReadAllBytes(@"D:\inor.pdf");
using (ClientContext context = new ClientContext(Properties.Settings.Default.SiteURL))
{
FileCreationInformation newFile = new FileCreationInformation()
{
Content = bytes,
Url = string.Format("inor9.pdf", DateTime.Now.Ticks)
};
List certificateList = context.Web.Lists.GetByTitle("Certificaten");
Microsoft.SharePoint.Client.File uploadFile = certificateList.RootFolder.Files.Add(newFile);
uploadFile.ListItemAllFields.ParseAndSetFieldValue("CertificateNumber", "356");
uploadFile.ListItemAllFields.Update();
context.Load(uploadFile);
context.ExecuteQuery();
}
But the problem with this code is that 2 versions are created version 0.1 and 0.2. I don't want 2 versions because i have an itemreceiver on the itemadded that needs this certificatenumber. ItemAdded is now fired before the certificatenumber is added.