Getting Directory and System Environment Information - CSharp System

CSharp examples for System:Environment

Description

Getting Directory and System Environment Information

Demo Code

using System;/*  w  ww. j  av a  2  s .  c om*/
class EnvApp
{
   public static void Main()
   {
      // Some Properties...
      Console.WriteLine("");
      Console.WriteLine(" Command: {0}", Environment.CommandLine);
      Console.WriteLine("Curr Dir: {0}", Environment.CurrentDirectory);
      Console.WriteLine(" Sys Dir: {0}", Environment.SystemDirectory);
      Console.WriteLine(" Version: {0}", Environment.Version);
      Console.WriteLine(" OS Vers: {0}", Environment.OSVersion);
      Console.WriteLine(" Machine: {0}", Environment.MachineName);
      Console.WriteLine("  Memory: {0}", Environment.WorkingSet);
      // Some methods...
      Console.WriteLine("");
      string [] args = Environment.GetCommandLineArgs();
      for ( int x = 0; x < args.Length; x++ )
      {
         Console.WriteLine("Arg {0}: {1}", x, args[x]);
      }
      Console.WriteLine("");
      string [] drives = Environment.GetLogicalDrives();
      for ( int x = 0; x < drives.Length; x++ )
      {
         Console.WriteLine("Drive {0}: {1}", x, drives[x]);
      }
      Console.WriteLine("");
      Console.WriteLine("Path: {0}",Environment.GetEnvironmentVariable("Path"));
      Console.WriteLine("");
   }
}

Result


Related Tutorials