I use following code to add file to SharePoint library using client object model.
Web web = context.Web;
FileCreationInformation newFile = new FileCreationInformation();
newFile.Content = System.IO.File.ReadAllBytes(filePath);
newFile.Url = destFileName;
newFile.Overwrite = true;
List docs = web.Lists.GetByTitle(listName);
Microsoft.SharePoint.Client.File uploadFile = docs.RootFolder.Files.Add(newFile);
context.Load(uploadFile);
context.ExecuteQuery();
Question is, can I include my comment during this routine itself?
As it stands, I have to checkout file again and check in with comments using following code, which makes 2 versions of file which is unnecessary.
if (uploadFile.CheckOutType != CheckOutType.None)
{
uploadFile.CheckOut();
context.ExecuteQuery();
}
uploadFile.CheckIn(checkinComments, checkinType);
context.ExecuteQuery();