1

私は、モバイルでも、どのWindowsバージョンでも実行できるアプリケーションを作成しており、実行可能ファイルの現在のディレクトリを取得しようとしています。問題は、次のコードを使用すると、WindowsMo​​bileでコンパイルされないことです。

string currentDirectory = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

そして、このコードを使用すると、次のようなものが表示されます:file:\ C:\ xxx

string currentDirectory = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

ただし、ルートドライブを取得する必要があり、このコードはWindowsMo​​bileでコンパイルされません。

String rootPath = Path.GetPathRoot(Environment.SystemDirectory);

アプリケーションの現在のディレクトリと、モバイルを含む任意のWindowsバージョンのルートパスを取得する方法を知っている人はいますか?

4

1 に答える 1

2

これらの線に沿った何か?

var folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)
于 2011-11-15T18:18:41.847 に答える