Export (0) Print
Expand All

HOW TO: Determine the Executing Application's Path

.NET Compact Framework 1.0

Applies to:
    Microsoft® .NET Compact Framework 1.0
    Microsoft® Visual Studio® .NET 2003

IN THIS TASK

SUMMARY

     Determine the Executing Application’s Path (VB)

     Determine the Executing Application’s Path (C#)

REFERENCES

SUMMARY

Learn how to determine the path of the currently executing application. In Embedded Visual Basic, the executing application path would be available through App.Path property. The executing application's path can be determined by examining the executing assembly's AssemblyName object, which fully describes the assembly's identity.

Determine the Executing Application’s Path (VB)

  1. Start Microsoft Visual Studio .NET.
  2. Create a new Visual Basic Smart Device Application project named AppPath.
  3. In the Smart Application Wizard, select the Pocket PC platform and Windows Application project type.
  4. Add a Button control to the form. The button is named Button1 by default.
  5. Right-click the form, and then click View Code.
  6. Add the following Click event handler for Button1:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim path As String
       path = System.IO.Path.GetDirectoryName( _
          System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
       MessageBox.Show(path)
    End Sub
    
    

Determine the Executing Application’s Path (C#)

  1. Start Microsoft Visual Studio .NET.
  2. Create a new Visual C# Smart Device Application project named AppPath.
  3. In the Smart Application Wizard, select the Pocket PC platform and Windows Application project type.
  4. Add a Button control to the form. The button is named button1 by default.
  5. Double click button1 to create a Click event handler
  6. Add the following code to the event handler:
    private void button1_Click(object sender, System.EventArgs e)
    {
       string path;
       path = System.IO.Path.GetDirectoryName( 
          System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );
       MessageBox.Show( path );
    }
    
    

REFERENCES

The Visual Studio .NET 2003 online help.

Show:
© 2014 Microsoft