Dynamically generate a .html page in console application c#
I would like to create a .html page dynamically inside a directory using c# console application
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Raghavendra JoshiPosted May 12, 2014, 9:21 AM
Software DevelopmentIT - Training Institute
I want to write it in a table format using writehtmlFile.WriteLine i.e each row consits of 3 columns
ex :
Anupam SinghPosted May 12, 2014, 6:13 AM
And answer of your 2nd question is to use StringBuilder to build html page and then you can save it to directory..
like
DataTable dt=new DataTable();
fill data in dt
StringBulider sb=new StringBuilder();
sb.append("");
sb.append(dt.Rows[0][0]);
.
.
sb.append("");
then you can use
writehtmlFile .WriteLine(sb);
Raghavendra JoshiPosted May 12, 2014, 5:29 AM
for example:-
->directory "x" consists "y.html" &
->directory "L" which will be inside directory "x" consists "m.html"
->"y.html" fetches data from database.
->"each link in "y.html" will be linked to "m.html"
I also have a question about fetching data from database table to a html file.
Anupam SinghPosted May 12, 2014, 4:24 AM
Raghavendra JoshiPosted May 12, 2014, 3:59 AM
Thank you, actually i have a very long html data which i am supposed to write it inside a directory. Do i need to write it in a single line or is there any other method to write it. Will you please help me out in this.
Thanks & Regards,
Raghavendra
Anupam SinghPosted May 12, 2014, 3:44 AM
you can simply use textwriter class
System.IO.TextWriter writehtmlFile = new StreamWriter("c:\\htmlfile.html");
writehtmlFile .WriteLine("your file text");
writehtmlFile .Flush();
writehtmlFile .Close();