private void button1_Click(object sender, EventArgs e)
{
string[] input = new string[] { "Web", "Images", "Gmail", "C:\\Users\\Amit_Personal\\Documents\\Visual Studio 2008\\Projects\\abc\\abc\\google_image_final.png", "Google Search", "I'm Lucky"};
// Pass the array as a parameter:
Designpage(input);
}
public void Designpage(string\[\] arr)
{
string fileLoc = @"C:\\Users\\Amit\_Personal\\Documents\\Visual Studio 2008\\Projects\\abc\\abc\\a.htm";
if (File.Exists(fileLoc))
{
using (StreamWriter s = File.AppendText(fileLoc))
{
// StringWriter s = new StringWriter();
s.WriteLine("{0}", "<!DOCTYPE HTML PUBLIC \\"-//W3C//DTD HTML 4.0 Transitional//EN\\">");
s.WriteLine("{0}", "<html>");
s.WriteLine("{0}", "<title>Google</title>");
s.WriteLine("{0}", "<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"style.css\\">");
s.WriteLine("{0}", "</head>");
s.WriteLine("{0}", "<body>");
s.WriteLine("<h4>{0} ", arr\[0\]);
s.Write("{0} ", arr\[1\]);
s.WriteLine("{0} </h4>", arr\[2\]);
s.WriteLine("<img src=\\"{0}\\" />",arr\[3\]);
s.WriteLine("{0}", "</body>");
s.WriteLine("{0}", "</html>");
s.WriteLine("{0}", "");
s.Close();
}
}
Any one Know how to write better code to generate a .html file using C# language..