We help IT Professionals succeed at work.

copying the computer name into a string or a textBox inside a windows form in C#

Good morning experts,

I am wondering if there Is a way to copy the computer name into a form (textBox or string) created in C#?

Thank you
Comment
Watch Question

AndyAinscowFreelance programmer / Consultant

Commented:
Environment.MachineName should be what you want
Commented:
Hi adamtrask,

Please use this code.
 private void Form1_Load(object sender, EventArgs e)
        {
            textBox1.Text = System.Windows.Forms.SystemInformation.ComputerName;
        }

Open in new window

Author

Commented:
Thank you very much