CF-Program on Desktop

  • Thread starter Thread starter Christian Stelte
  • Start date Start date
C

Christian Stelte

Hi!

I've tried to write a CF-Program that would run also on the
Desktop-Framework. There are some things where I must use different code. Eg
to get the StartUpPath. As you told me to determinate the Plattform by using
'System.Environment.OSVersion.Platform'.

I've tried this:

if (System.Environment.OSVersion.Platform == PlatformID.WinCE)
StartupPath =
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssem
bly().GetName().CodeBase);
else
StartupPath = Application.StartupPath;

This creates a 'System.Windows.Forms.Application' does not contain a
definition for 'StartupPath' Error-Message.

Clearly!

What must I do to get this? Compile with the Desktop-framework?

Chris
 
You cannot use Application.StartupPath as although you are running on the
desktop you are building against the functionality of the compact framework.
You should find that the same method:-
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssem
bly().GetName().CodeBase);

Will work equally well on the desktop and will give you a valid desktop path
to your application e.g. "C:\Program Files\My App\MyApp.exe"

Peter
 
Back
Top