Hi All,
I am using this code to convert infopath view to html, everything working fine but i want to change the file location
public string ConvertViewToHtml()
{
try
{
byte[] sourceFile = null;
XPathNavigator root = MainDataSource.CreateNavigator();
//string myViewName = this.CurrentView.ViewInfo.Name.Replace(" ", string.Empty);
string myViewName = "Email";
string myViewXslFile = myViewName + ".xsl";
// Create the xsl transformer
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load(ExtractFromPackage(myViewXslFile));
// Generate a temporary HTML file
string fileName = Guid.NewGuid().ToString() + ".htm";
string filePath = Path.Combine(Path.GetTempPath(), fileName);
using (XmlWriter writer = XmlWriter.Create(filePath))
{
// Convert the XML to HTML
transform.Transform(root, writer);
writer.Close();
}
// Return the HTML as a string
sourceFile = File.ReadAllBytes(filePath);
return System.Text.Encoding.UTF8.GetString(sourceFile);
}
catch (Exception ex)
{
return "<html><body>Unable to convert the view to HTML <p>" + ex.Message + "</p></body></html>";
}
}By default file get stored in this location 'C:\Users\TEMP.EGA\AppData\Local\Temp\64aa2af2-4f7f-44e9-afdc-6783f7f4007d.htm'. But I want to store in different location. How to achieve this? Thanks in advance!