Skip to content

Application.StartupPath

Marshall

Asked Apr 25, 2007, 3:37 AM EDT6 answers
Share
LinkedInX
Hello all:

I'm a new C# dude so apologize for the simplicity...

I was given a solution in another thread that I cannot seem to duplicate?

In C# VS2005, I'm simply trying to get the application startup path BUT in the IDE when I type "Application." only DoEvents, Equals, Exit, ReferenceEquals and Run show up as possible selections??? Manually typing "StartupPath" gives me an error. Is there a declaration I'm missing?

Thank you

Marshall

6 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • kamalakar rao
    0

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Text;

    using System.Windows.Forms;

    These are all default imports when we would create new project in VS 2005
    For myself Application.StartupPath is working.

    0
  • 0
    Kamal:

    I've got the same uses items with the addition of System.IO and still cannot get the Application.StartupPath to work??? I'm now installing SP1 to see if this fixes the problem. I'm an old Borland C++ Builder person and this is quite frustrating in my first venture into MFC VS. I like mostly what I see but am finding that the code examples don't exactly work as pictured.

    Thank you
    0
  • 0
    That sounds very odd. In your code, can you try using a fully-qualified namespace, just to be sure it isn't a conflicting Application object.

    string path = System.Windows.Forms.Application.StartupPath;

    Other than that, as it's been said, it should just work. You can check your project references to see that System.Windows.Forms is pointing to a v2.0. If you create a new Windows Forms C# project you should be able to see the .StartupPath property. If not then something is very wrong with your .Net framework.
    0
  • 0
    Well, I think I understand how this works!

    MY app is a smartdevice app for PPC2003 and above which uses the Compact Framework 2.0 . This being a subset of the .NET Framework 2.0 ... guess what ? StartupPath is not implemented in the CF2.0. My bad guys!

    Appreciate the help!

    Thank you

    Marshall
    0
  • 0

     May be you can try using System.Enviroment.CurrentDirectory ..

    0
  • 0
    That works!

    Thank you

    Marshall
    0