在Windows Mobile和Wince(Windows Embedded CE)下使用.NET Compact Framework 取当前运行文件的路径

问题

.NET Compact Framework 提供了Directory.GetCurrentDirectory Method 取当前运行文件的目录,可是运行的时候会抛出 NotSupportedException

这个问题MSND的解释如下:

The operating system is Windows CE, which does not have current directory functionality.

This method is available in the .NET Compact Framework, but is not currently supported.

 

替代方案

使用 Path.GetDirectoryName MethodAssemblyName.CodeBase Property 来代替。

System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
posted @ 2009-07-29 09:41  Jake Lin  阅读(2027)  评论(3编辑  收藏  举报