---
title: "How can create a HTML file via console programming ?"  
description: "How can create a HTML file via console programming ?"  
author: "MindStick Software Pvt Ltd"  
published: 2019-09-13  
updated: 2019-09-13  
canonical: https://www.mindstick.com/forum/95360/how-can-create-a-html-file-via-console-programming  
category: "c#"  
tags: ["c#", "visual studio", "visual studio 2012"]  
reading_time: 3 minutes  

---

# How can create a HTML file via console programming ?

How can create an [HTML](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript) [file](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp) via [console](https://www.mindstick.com/blog/210/the-console-class) [programming](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming)?

## Replies

### Reply by Kristy

Thanks for asking this I was also looking for the same. Keep posting and help people like me. Assignment Writing Service

### Reply by Anonymous User

Step (1) - Add a new empty project.\
![How can create a HTML file via console programming ?](https://www.mindstick.com/mindstickforums/2cac32de-1b42-4274-911a-a8a2561fd197/images/2b747b26-f82d-4fa8-b36f-5b8702b165ce.png)\
Step (2) - Add a class file (.cs)

write this code :-

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace HTML_File_Console_CS
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Name:");
            string name = Console.ReadLine();

            //Table start.
            string html = "<table cellpadding='5' cellspacing='0' style='border: 1px solid #ccc;font-size: 9pt;font-family:arial'>";

            //Adding HeaderRow.
            html += "<tr>";
            html += "<th style='background-color: #B8DBFD;border: 1px solid #ccc'>Name</th>";
            html += "</tr>";

            //Adding DataRow.

                html += "<tr>";
                html += "<td style='width:120px;border: 1px solid #ccc'>" + name + "</td>";
                html += "</tr>";


            //Table end.
            html += "</table>";

            //Create the HTML file.
            File.WriteAllText(@"C:\Users\msclient007.MSSERVER001\Desktop\Testhtml\Console.htm", html);

            Console.WriteLine("HTML File created.");
            Console.ReadLine();
        }
    }
}
```

![How can create a HTML file via console programming ?](https://www.mindstick.com/mindstickforums/2cac32de-1b42-4274-911a-a8a2561fd197/images/917cdecf-8116-43dd-975c-b44b005575a5.png)

## Assemblyinfo.cs

```
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("HTML_File_Console_CS")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HTML_File_Console_CS")]
[assembly: AssemblyCopyright("Copyright ©  2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components.  If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9bf1e99f-75df-4118-9f28-5eaa3313f454")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
```

![How can create a HTML file via console programming ?](https://www.mindstick.com/mindstickforums/2cac32de-1b42-4274-911a-a8a2561fd197/images/c5d95a92-f8cd-44d2-9fc9-c53bb368702d.png) **\**

Create a folder on desktop for saving the Html file.


---

Original Source: https://www.mindstick.com/forum/95360/how-can-create-a-html-file-via-console-programming

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
