Recent request from a customer:

What we need to be able to do is to somehow programmatically access, in infopath, the sharepoint form library folder name from which the form was opened.

Cool way to get this done (from Scott Heim's inexhaustible code sample archive):

substring-before(substring-after(/processing-instruction(), 'href="'), '"')

 

Used as the default value in a text box returns this:

 

http://servername/URITest/Forms/template.xsn

 

In this case, as you can see from the returned URL, the form was opened from my document library “URITest”