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
Application.StartupPath
6 Answers
Know the answer? Post it. Somebody with the same question will find it here.
kamalakar rao24 pointsPosted Apr 25, 2007, 4:40 AM EDT
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.
Marshall16 pointsPosted Apr 25, 2007, 7:26 AM EDT
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
Sokak37 pointsPosted Apr 26, 2007, 2:32 PM EDT
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.
Marshall16 pointsPosted Apr 27, 2007, 12:22 PM EDT
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
Huang Elite6 pointsPosted Apr 28, 2007, 7:07 PM EDT
May be you can try using System.Enviroment.CurrentDirectory ..
Marshall16 pointsPosted Apr 30, 2007, 3:16 AM EDT
Thank you
Marshall