I am using sharepoint CSOM to download / upload file from a OneDriveBusiness account.
Before downloading the file I need to check if the file is currently in use. File.CheckOutType is alway "None". I though using File.LockedByUser property, using the following code, but I got a ServerObjectNullReferenceException when the file is not locked.
var listItem = clientDocs.GetItemById(item.Id);
clientContext.Load(listItem.File.LockedByUser);
clientContext.ExecuteQuery();
var locked = listItem.File.LockedByUser.UserId;
I was hoping to be able to do do something like :
if (file."locked")
{
throw exception...
}
enter code here
Any idea ? Thanks !