.NET
  Home arrow .NET arrow Knowing Your Environment: the System.Envir...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Knowing Your Environment: the System.Environment Class
By: Ayad Boudiab
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-05-12

    Table of Contents:
  • Knowing Your Environment: the System.Environment Class
  • More Properties
  • More Explanations
  • Methods

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Knowing Your Environment: the System.Environment Class


    (Page 1 of 4 )

    When developing applications (Windows or web), it is very important for the developer to know the environment in which the application is running. Having this information will help the developer customize the software and make the user experience more enjoyable. In this regard, .NET provides a class in the System namespace called Environment, which is the subject of this article.

    The environment class contains methods and properties that provide information about the current environment and platform. It is important to note that this class cannot be inherited. In other words, you cannot extend the functionality in this class to create your own class.

    Here is a rundown of some of the handy methods and properties that this class provides, with minor explanation on the usage of each.

    Properties

    CommandLine: The call to Environment.CommandLine will provide the full name of the application, followed by the command line arguments. The command line arguments are the pieces of data entered after the application name. For example:


    Multiply.exe x1 x2


    In this case, x1 and x2 are the command line arguments. In order to get access to x1 and x2, you use the args array passed to the Main method. Here is the method signature:


    static   void Main( string [] args)


    Visual Studio provides two ways to enter the command line arguments:

    1. By running the application from the command prompt.

    2. By entering the arguments in the Debug tab of the project properties:



    Here is a statement that shows how you access the CommandLine property:


    //returns a string containing command-line arguments

    Console .WriteLine( "The command line is: " + Environment .CommandLine);

    More .NET Articles
    More By Ayad Boudiab


       · Hello everyone,Here is my latest article on the System.Environment class.Please...
     

    .NET ARTICLES

    - Building Applications with Windows Workflow ...
    - Building the Data and Business Layers Using ...
    - The Transformed XML Explorer in MFC
    - List Control and Property Grid with the MFC ...
    - Font, Shell and Masked Edit Controls for MFC
    - Color, Link and Image Editor Controls for M...
    - New Controls for MFC
    - The Windows Ribbon Framework
    - Markup Language for the Ribbon Framework
    - Visually Upgrade Your MFC Project
    - New Features for the Statusbar in MFC
    - Working with the Statusbar in MFC
    - Iron Speed Design v60 Review
    - Binary and XML Serialization
    - Using CrystalReportViewer to Display Crystal...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek