I found a solution by using the xml writer function and creating the second separate form within the code of the first form.
private void buildForm(string firstChecker, string secondChecker, string firstCheckerName, string secondCheckerName, string location)
{
byte[] infoPathFormData = null;
using (MemoryStream ms = new MemoryStream())
{
using (XmlTextWriter writer = new XmlTextWriter(ms, Encoding.UTF8))
{
// Define the namespace for the form
string myNamespace = "http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-05-15T17:11:38";
writer.WriteStartDocument();
writer.WriteProcessingInstruction(
"mso-infoPathSolution",
"solutionVersion=\"1.0.0.12\" productVersion=\"12.0.0\" PIVersion=\"1.0.0.0\" href=\"http://teamsites.??.com/???/Templates/Conversion%20Checker%20Queue/forms/Conversion%20Checker%20Queue.xsn\" name=\"urn:schemas-microsoft-com:office:infopath:Conversion-Checker-Queue:-myXSD-2012-05-15T17-11-38\"");
writer.WriteProcessingInstruction(
"mso-application",
"progid=\"InfoPath.Document\" versionProgid=\"InfoPath.Document.2\"");
// Create the XML of the main data source of the form
writer.WriteStartElement("my", "myFields", myNamespace);
writer.WriteStartElement("my", "firstChecker", myNamespace);
writer.WriteString(firstChecker);
writer.WriteEndElement();
writer.WriteStartElement("my", "secondChecker", myNamespace);
writer.WriteString(secondChecker);
writer.WriteEndElement();
writer.WriteStartElement("my", "firstCheckerName", myNamespace);
writer.WriteString(firstCheckerName);
writer.WriteEndElement();
writer.WriteStartElement("my", "secondCheckerName", myNamespace);
writer.WriteString(secondCheckerName);
writer.WriteEndElement();
writer.WriteStartElement("my", "location", myNamespace);
writer.WriteString(location);
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
infoPathFormData = ms.GetBuffer();
ms.Close();
}
// Upload the newly created InfoPath form to SharePoint
if (infoPathFormData != null && infoPathFormData.Length != 0)
{
using (WebClient client = new WebClient())
{
// Set the credentials to be used for upload to SharePoint
client.Credentials = CredentialCache.DefaultCredentials;
string url = "http://teamsites.??.com/???/Templates/Conversion%20Checker%20Queue/" + System.DateTime.Now.ToString("yyyy-MM-ddTHH_mm_ss") + ".xml";
// Upload the newly created form to a SharePoint form library
client.UploadData(@url, "PUT", infoPathFormData);
}
}
}