config file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Concept
    New Member
    • Dec 2007
    • 4

    #1

    config file

    Hi All,

    I want to open an application from a config file using c#. I'm new to both c# and writing config files and don't really know where to start. Please help.....openin g any app will do for now.

    Cheers,

    Concept
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi ,

    First of all ,
    Are you using Asp.net and for what purpose you are using Config file for opening the application?
    So please specify more details about it.

    To do this , define the key in the Web.config under appSettings section like this

    <app settings>
    <key name = "App_Path" value ="/application.exe ">
    </app settings>

    In the application define a function to open a application
    e.g.

    Code:
    public void RunApp() 
    { 
    
        //Get the application path from configuration file
        string AppPath = System.Configuration.ConfigurationManager.AppSettings("keyname"); 
        System.Diagnostics.Process.Start(AppPath); 
    }


    Originally posted by Concept
    Hi All,

    I want to open an application from a config file using c#. I'm new to both c# and writing config files and don't really know where to start. Please help.....openin g any app will do for now.

    Cheers,

    Concept

    Comment

    • Concept
      New Member
      • Dec 2007
      • 4

      #3
      I'm using asp.net.

      This worked Thank you.

      I have another question. If the application doen't exist at the location that is given in the value in the key in the config file, is it possible display to an error page?

      Thanks again.

      Originally posted by shweta123
      Hi ,

      First of all ,
      Are you using Asp.net and for what purpose you are using Config file for opening the application?
      So please specify more details about it.

      To do this , define the key in the Web.config under appSettings section like this

      <app settings>
      <key name = "App_Path" value ="/application.exe ">
      </app settings>

      In the application define a function to open a application
      e.g.

      Code:
      public void RunApp() 
      { 
      
          //Get the application path from configuration file
          string AppPath = System.Configuration.ConfigurationManager.AppSettings("keyname"); 
          System.Diagnostics.Process.Start(AppPath); 
      }

      Comment

      • radcaesar
        Recognized Expert Contributor
        • Sep 2006
        • 759

        #4
        Put that code inside a try catch block.

        Bind the error message in the catch block

        like, lblErr.Text=Ex. Message, Where Ex is the instance of Exception class

        Comment

        Working...