How can create a HTML file via console programming ?

Total Post:3

Points:21

C#
 1418  View(s)
Ratings:
Rate this:

How can create an HTML file via console programming?

  1. Re: How can create a HTML file via console programming ?

    Step (1) - Add a new empty project.
    How can create a HTML file via console programming ?
    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.");
                Conso
    le.ReadLine();
            }
        }
    }

    How can create a HTML file via console programming ?

    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: AssemblyFi
    leVersion("1.0.0.0")]

    How can create a HTML file via console programming ?

    Create a folder on desktop for saving the Html file.

  1. Re: How can create a HTML file via console programming ?

    Thanks for asking this I was also looking for the same. Keep posting and help people like me. Assignment Writing Service

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.