且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2021-09-01 21:30:12

问题

.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 Method 和 AssemblyName.CodeBase Property 来代替。

System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);



本文转自Jake Lin博客园博客,原文链接:http://www.cnblogs.com/procoder/archive/2009/07/29/Windows_Mobile_Compact_Framework_Path.html,如需转载请自行联系原作者