I want try to get Infopath form id after add to form library by following code

spFile = fileLibrary.Files.Add(fileName, fileContents, replaceExistingFiles);

and I can't access spFile.Item.Id because I added file to form library and I receive this error:

The object specified does not belong to a list.

Is there any efficient way to get id by name? I tried to get id by file URL but there is no Item.Id again.

  • I think its case sensitive. Try using spFile.Item.ID
    – Asad Refai
    Mar 3 '16 at 12:33
  • thanks for your replay and of curse its case sensitive and if its wrong error occurs on compile time not run time
    – Mehdi
    Mar 4 '16 at 15:55
  • No worries. I posted as an answer.
    – Asad Refai
    Mar 4 '16 at 16:17

The properties are case sensitive in SharePoint. Normally its ID

So try below code


This should solve the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.