FileInfo.Directory プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > FileInfo.Directory プロパティの意味・解説 

FileInfo.Directory プロパティ

親ディレクトリインスタンス取得します

名前空間: System.IO
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Dim instance As FileInfo
Dim value As DirectoryInfo

value = instance.Directory
public DirectoryInfo Directory { get; }
public:
property DirectoryInfo^ Directory {
    DirectoryInfo^ get ();
}
/** @property */
public DirectoryInfo get_Directory ()

プロパティ
ファイル親ディレクトリを表す DirectoryInfo オブジェクト

例外例外
例外種類条件

DirectoryNotFoundException

割り当てられていないドライブであるなど、指定されパス無効です。

SecurityException

呼び出し元に必要なアクセス許可がありません。

解説解説
使用例使用例

ファイルを開くか作成して、その絶対パス判別しディレクトリの完全な内容判別し表示する例を次に示します

Imports System
Imports System.IO

Public Class DirectoryTest

    Public Shared Sub Main()
        ' Open an existing file, or create a new one.
        Dim fi As New FileInfo("temp.txt")

        ' Determine the full path of the file just created.
        Dim di As DirectoryInfo = fi.Directory

        ' Figure out what other entries are in that directory.
        Dim fsi As FileSystemInfo() = di.GetFileSystemInfos()

        ' Print the names of all the files and subdirectories of that
 directory.
        Console.WriteLine("The directory '{0}' contains the following
 files and directories:", di.FullName)
        Dim info As FileSystemInfo
        For Each info In
 fsi
            Console.WriteLine(info.Name)
        Next info
    End Sub 'Main
End Class 'DirectoryTest
using System;
using System.IO;

public class DirectoryTest 
{
    public static void Main()
 
    {

        // Open an existing file, or create a new one.
        FileInfo fi = new FileInfo("temp.txt");

        // Determine the full path of the file just created.
        DirectoryInfo di = fi.Directory;

        // Figure out what other entries are in that directory.
        FileSystemInfo[] fsi = di.GetFileSystemInfos();

        Console.WriteLine("The directory '{0}' contains the following files
 and directories:", di.FullName);

        // Print the names of all the files and subdirectories of that
 directory.
        foreach (FileSystemInfo info in fsi)
            Console.WriteLine(info.Name);
    }
}
using namespace System;
using namespace System::IO;
int main()
{
   
   // Open an existing file, or create a new one.
   FileInfo^ fi = gcnew FileInfo( "temp.txt" );
   
   // Determine the full path of the file just created.
   DirectoryInfo^ di = fi->Directory;
   
   // Figure out what other entries are in that directory.
   array<FileSystemInfo^>^fsi = di->GetFileSystemInfos();
   Console::WriteLine( "The directory '{0}' contains the following files and
 directories:", di->FullName );
   
   // Print the names of all the files and subdirectories of that directory.
   Collections::IEnumerator^ myEnum = fsi->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      FileSystemInfo^ info = safe_cast<FileSystemInfo^>(myEnum->Current);
      Console::WriteLine( info->Name );
   }
}

import System.*;
import System.IO.*;

public class DirectoryTest
{
    public static void main(String[]
 args)
    {
        // Open an existing file, or create a new one.
        FileInfo fi = new FileInfo("temp.txt");

        // Determine the full path of the file just created.
        DirectoryInfo di = fi.get_Directory();

        // Figure out what other entries are in that directory.
        FileSystemInfo fsi[] = di.GetFileSystemInfos();
        Console.WriteLine("The directory '{0}' contains the following files
 " 
            + " and directories:", di.get_FullName());

        // Print the names of all the files and subdirectories of
        // that directory.
        for (int iCtr = 0; iCtr < fsi.length;
 iCtr++) {
            FileSystemInfo info = (FileSystemInfo)fsi.get_Item(iCtr);
            Console.WriteLine(info.get_Name());
        }
    } //main
} //DirectoryTest
import System;
import System.IO;

public class DirectoryTest {
    public static function
 Main() : void {

        // Open an existing file, or create a new one.
        var fi : FileInfo = new FileInfo("temp.txt");

        // Determine the full path of the file just created.
        var di : DirectoryInfo = fi.Directory;

        // Figure out what other entries are in that directory.
        var fsi : FileSystemInfo[] = di.GetFileSystemInfos();

        Console.WriteLine("The directory '{0}' contains the following files
 and directories:", di.FullName);

        // Print the names of all the files and subdirectories of that
 directory.
        for (var i : int
 in fsi)
            Console.WriteLine(fsi[i].Name);
    }
}
DirectoryTest.Main();
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からFileInfo.Directory プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からFileInfo.Directory プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からFileInfo.Directory プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

FileInfo.Directory プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



FileInfo.Directory プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS