Dyamic HTML Page Creation

I want to create web page based on a string that's actually HTML code. How can I have this automatically done For example, so I can base my code off of this example, how would have an html file created (in the user's Temp directory) that contains the code from a textbox

As I wrote this, I was thinking about creating a textfile and writing to the textfile and renaming the textfile to a .html, but can someone give an example of code to do this, because I'm not sure about the whole process. I think I would use a writealltext method to do that, is that correct




Answer this question

Dyamic HTML Page Creation

  • Erick-Flores

    Hello,

    I didn't understand your problem to well but here goes.

    So, you want to save text from a text box into a HTML file Create a new form, insert a text box, insert a button. On the click event for the button insertt the following:

    StreamWriter sw = new StreamWriter("C:\\Index.html",false);

    sw.Write(txtHtmlCode.Text);

    sw.Close();

    Thats it!

    You can get the user's temp directory by using the following:

    Environment.GetEnvironmentVariable("TEMP");

    Cheers,

    Luc


  • tssweb

    Totally overlooked Environment.GetEnvironmentVariable("TEMP"); , I was using environmental variables in the path like %APPDATA% to store application related temporary information.

    But yes a very confusing post with no real question or direction.


  • Nick Humphries

    Thanks all. I was expecting Environment.SpecialFolder.TempDirectory (I dunno if that exists), but what you said will work. (I'm Geek btw)


  • Dyamic HTML Page Creation