Print all properties of Environment class
If you need a quick overview of the system configuration you can use this code snippet:
public class EnvironmentHelper
{
public static string GetAllEnvironmentInformations()
{
StringBuilder builder = new StringBuilder();
Type type = typeof(Environment);
PropertyInfo[] propertyInfos = type.GetProperties();
foreach (PropertyInfo propertyInfo in propertyInfos)
{
object value = propertyInfo.GetValue(null, null);
if( value != null)
{
builder.AppendLine(propertyInfo.Name + ": " + value);
}
}
return builder.ToString();
}
}
Advertisement
Leave a Comment