Hi all, i try this code that i found:
// Get the connection to the SharePoint library
SharepointListQueryConnection spsConn =
(SharepointListQueryConnection)DataSources["Datasource"].QueryConnection;
// Retrieve the name of the form from the current row
string formName = e.Source.CreateNavigator().SelectSingleNode("@Titulo", NamespaceManager).Value;
// Generate the URL to the form
string formUrl = String.Format("{0}{1}/{2}", spsConn.SiteUrl, spsConn.Name, formName);
// Get an XPathNavigator object to the GetItem method of the Copy web service
XPathNavigator root = DataSources["GetItem"].CreateNavigator();
// Set the Url parameter on the GetItem method
root.SelectSingleNode("//*[local-name()='Url']").SetValue(formUrl);
// Call the web service
DataSources["GetItem"].QueryConnection.Execute();
// Get the byte array stream of the form from the web service response
XPathNavigator formStream = root.SelectSingleNode("//*[local-name() = 'Stream']");
// Convert the base64 encoded string for the form into a byte array
byte[] formData = Convert.FromBase64String(formStream.Value);
/*
Once you've converted the base64 encoded string for the form
into a byte array, you can do whatever you like with that
byte array. Here we will continue converting it to a string and
then create a temporary file of that string so that we can open
the temporary file in InfoPath.
*/
// Convert the form's byte array into a string
string formString = string.Empty;
using (MemoryStream ms = new MemoryStream(formData, false))
{
using (StreamReader sr = new StreamReader(ms, Encoding.UTF8))
{
formString = sr.ReadToEnd();
sr.Close();
}
ms.Close();
}
// Create a temporary file to write the text of the form to
string tempFileName = Path.GetTempFileName();
using (FileStream fs = new FileStream(tempFileName, FileMode.Open, FileAccess.ReadWrite))
{
using (StreamWriter sw = new StreamWriter(fs))
{
sw.Write(formString);
sw.Flush();
sw.Close();
}
fs.Close();
}
// Open the temporary file for the form in a new instance of InfoPath
Application.XmlForms.Open(tempFileName);
I create the datasources for get list and put GetLIst work, and i define this in code:
using System.IO;
using System.Text;
but i got this mesage:
Exception Message: Object reference not set to an instance of an object
the fail in this line:
string formName = e.Source.CreateNavigator().SelectSingleNode("@Titulo", NamespaceManager).Value;
thanks for help