Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
If there is a file in a document library in this structure:
How do I get the reference to DocumentSet from the file with server side object model?
You will need to break the URL apart. The item url is basically list/folder[x]/item.
Credits to Bunzab
Required, but never shown