Share via


方法 : アプリケーション ディレクトリを取得します。

[このドキュメントはプレビュー版であり、後のリリースで変更されることがあります。 空白のトピックは、プレースホルダーとして挿入されています。]

Pocket PC アプリケーションで固有の現在のディレクトリ設定がないパスを指定しないと、コードでファイル名を指定する、FileNotFoundException を返します。 Pocket PC アプリケーションが \Program Files\ myAssembly下には、アセンブリ ファイルのデータ ファイルを格納 \ 場所 myAssembly の は、アセンブリの名前。

使用例

実行アセンブリの完全修飾ディレクトリ名を取得して、アプリケーションのファイル名で追加、現在実行中のアプリケーションのパスを確認するには次の使用例に示します。 することを確認アプリケーションは、デバイスのルート ディレクトリに実行されている場合、返されるパス情報を空にします。

                        Dim strAppDir AsString = Path.GetDirectoryName( _
    Assembly.GetExecutingAssembly().GetName().CodeBase)
Dim strFullPathToMyFile AsString = Path.Combine(strAppDir, "myFileName.txt")

MessageBox.Show(String.Format("Path to the application is: '{0}'." + _
    "Full path to the file in the application folder is: '{1}'", _
    strAppDir, strFullPathToMyFile))
        String strAppDir = Path.GetDirectoryName(
            Assembly.GetExecutingAssembly().GetName().CodeBase);
        String strFullPathToMyFile = Path.Combine(strAppDir, "fileName.txt");

        MessageBox.Show(String.Format("Path to the application is: '{0}'." +
            "Full path to the file in the application folder is: '{1}'",
            strAppDir, strFullPathToMyFile));
                                                                                                                                

コードのコンパイル方法

この例では、次の名前空間への参照が必要です。

参照

その他の技術情報

Pocket PC の開発と、.NET Framework を最適化します。

アプリケーションおよび .NET Compact Framework のコア タスクの構築