test_readplant_test_visuals.../Test_ReadPlant/Form1.cs

45 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Test_ReadPlant
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void buttonStart_Click(object sender, EventArgs e)
{
try
{
string result = "Ergebnis:\nVariable wird initialisiert.";
labelResult.Text = result;
string plant = "";
result = String.Concat(result, "\nEinlesen der Umgebungsvariale 'PLANT' wird versucht.");
labelResult.Text = result;
plant = Environment.GetEnvironmentVariable("PLANT");
result = String.Concat(result, "\nDer Wert der Umgebungsvariable ist: ", plant);
labelResult.Text = result;
if (string.IsNullOrEmpty(plant))
{
result = String.Concat(result, "\n\nACHTUNG: Der Wert konnte nicht ausgelesen werden!");
}
labelResult.Text = result;
}
catch (Exception)
{
MessageBox.Show("Es ist ein nicht näher definierter Fehler aufgetreten.");
}
}
}
}