locked
How to change location of the file? RRS feed

  • Question

  • 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!

    Saturday, January 24, 2015 4:32 PM

Answers

All replies

  • try these links

    http://walisystems.com/articles/sps/infoattach/copyingfileattachments.htm

    http://walisystems.com/articles/sps/infoattach/copyingfileattachments.htm

    https://support.microsoft.com/kb/2517906?wa=wsignin1.0

    https://support.office.com/en-sg/article/Change-the-programming-language-of-a-form-template-389dd24e-629a-49ce-9cd8-d8455879e268

    https://support.office.com/en-sg/article/Change-the-programming-language-of-a-form-template-389dd24e-629a-49ce-9cd8-d8455879e268

    ---------------------------------------------------------------------------------------------------------------------------

    Please mark as answer if you find it useful else vote for it if it is close to answer..happy sharepointing

    Monday, January 26, 2015 1:10 PM
  • Hi,

    You can change the line of code below

     string filePath = Path.Combine(Path.GetTempPath(), fileName);
    

    to

    string path= "c:\\temp";
    string filePath = Path.Combine(path, fileName);

    More information:

    https://msdn.microsoft.com/en-us/library/fyy7a5kt(v=vs.110).aspx

    Best Regards


    Dennis Guo
    TechNet Community Support

    • Proposed as answer by Patrick_Liang Friday, February 6, 2015 2:16 AM
    • Marked as answer by Patrick_Liang Saturday, February 7, 2015 1:05 AM
    Tuesday, February 3, 2015 3:44 AM