GetCurrentDirectory in CF

  • Thread starter Thread starter Robert Hanson
  • Start date Start date
R

Robert Hanson

I am trying to get the current directory in Compact Framework in order
to load a XML file loaded there. Is there a workaround for the
Directory.GetCurrentDirectory?

Thanks for any help!!

Bob Hanson
Centare Group Ltd.
 
Windows CE does not have the concept of a current directory. What you can
get is the directory the app is running from, see:
http://www.opennetcf.org/Forums/topic.asp?TOPIC_ID=86. An easier method to
get the application's path is using the ApplicationEx.StartupPath property
that is available in OpenNETCF.org's Smart Device Framework.

Regards,
 
Windows CE has no concept of 'current directory', so .NET CF does not
either. You'll have to code the full directory path into anything that
needs a path.

Paul T.
 
Try this ...

string sPath = Path.GetDirectoryName(
Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName );
 
You should use GetCallingAssembly, not GetExecutingAssembly becasue if you
put this in a DLL that ends up in the \Windows folder, you'll always get t
\Windows as the path.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


Fred Pizarro said:
Try this ...

string sPath = Path.GetDirectoryName(
Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName );

Robert Hanson said:
I am trying to get the current directory in Compact Framework in order
to load a XML file loaded there. Is there a workaround for the
Directory.GetCurrentDirectory?

Thanks for any help!!

Bob Hanson
Centare Group Ltd.
 
Back
Top