At any rate, Here's what I'm doing right now. I get the browser form's URI and then pull the library name out of that.
For the sake of organization, paste this snippet right underneath the comment block that talks about member variables:
private object _strUri
{
get { return FormState["_strUri"]; }
set { FormState["_strUri"] = value; }
}
In my form load event code ( Tools > Programming > Loading Event... ):
_strUri = e.InputParameters["SaveLocation"].ToString();
In my submit code:
// Get URI
string sUri = _strUri.ToString();
// Extract library name
int nUriLastSlashIndex = sUri.LastIndexOf('/');
int nUriSecondToLastSlashIndex = sUri.LastIndexOf('/', nUriLastSlashIndex - 1);
int nLibraryStringStartPosition = nUriSecondToLastSlashIndex + 1;
int nLibraryStringLength = nUriLastSlashIndex - nUriSecondToLastSlashIndex - 1;
string sLibrary = sUri.Substring(nLibraryStringStartPosition, nLibraryStringLength);
// Write the value to somewhere in the form
XPathNavigator xpnThis = this.MainDataSource.CreateNavigator();
xpnThis.SelectSingleNode("/my:myFields/my:FormSuppliments/my:FormLibraryName", this.NamespaceManager).SetValue(sLibrary);
EDIT: Ok, I've looked it up and this little code snippet isn't technically 'supposed' to work unless you close the form and reopen it exactly as I said I /didn't/ want to do. I have no idea how I had it working. Anyway it did jus break for me but fortunately I found a fix so I've edited it in.