What would be the best approach for finding out the site and web if all we have is a URL? The problem is, it can be multiple things:
- https://foo.bar/Library/file.png: a file living in the https://foo.bar/ site and the / web
- https://foo.bar/subsite/Library/file.png: site https://foo.bar/, web /subsite
- https://foo.bar/subsite1/subsite2/Library/file.png: site https://foo.bar/, subsite /subsite1/subsite2/
- etc, etc
So, essentially, what I am asking is: what would be the best approach/algorithm for, given a ClientContext (or some other client API), allowing me to figure out the site and the web where the file lives. From there I should be able to easily access the library and the file itself. Looking for .NET-based approach, if possible.