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

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

DirectoryInfo.Parent プロパティ

指定されサブディレクトリ親ディレクトリ取得します

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

Dim instance As DirectoryInfo
Dim value As DirectoryInfo

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

プロパティ
親ディレクトリ。または、パスnull であるか、ファイル パスルート ("\"、"C:"、* "\\server\share" など) を示している場合null 参照 (Visual Basic では Nothing)。

例外例外
解説解説
使用例使用例

指定したディレクトリ親ディレクトリ参照する例を次に示します

Imports System
Imports System.IO

Public Class MoveToTest

    Public Shared Sub Main()
        ' Make a reference to a directory.
        Dim di As New DirectoryInfo("TempDir")
        ' Create the directory only if it does not already exist.
        If di.Exists = False Then
            di.Create()
        End If

        ' Create a subdirectory in the directory just created.
        Dim dis As DirectoryInfo = di.CreateSubdirectory("SubDir")

        ' Get a reference to the parent directory of the subdirectory
 you just made.
        Dim parentDir As DirectoryInfo = dis.Parent
        Console.WriteLine("The parent directory of '{0}'
 is '{1}'", dis.Name, parentDir.Name)

        ' Delete the parent directory.
        di.Delete(True)
    End Sub 'Main
End Class 'MoveToTest
using System;
using System.IO;

public class MoveToTest 
{
    public static void Main()
 
    {

        // Make a reference to a directory.
        DirectoryInfo di = new DirectoryInfo("TempDir");

        // Create the directory only if it does not already exist.
        if (di.Exists == false)
            di.Create();

        // Create a subdirectory in the directory just created.
        DirectoryInfo dis = di.CreateSubdirectory("SubDir");

        // Get a reference to the parent directory of the subdirectory
 you just made.
        DirectoryInfo parentDir = dis.Parent;
        Console.WriteLine("The parent directory of '{0}' is '{1}'", dis.Name,
 parentDir.Name);

        // Delete the parent directory.
        di.Delete(true);
    }
}
using namespace System;
using namespace System::IO;
int main()
{
   
   // Make a reference to a directory.
   DirectoryInfo^ di = gcnew DirectoryInfo( "TempDir" );
   
   // Create the directory only if it does not already exist.
   if (  !di->Exists )
      di->Create();

   
   // Create a subdirectory in the directory just created.
   DirectoryInfo^ dis = di->CreateSubdirectory( "SubDir" );
   
   // Get a reference to the parent directory of the subdirectory you
 just made.
   DirectoryInfo^ parentDir = dis->Parent;
   Console::WriteLine( "The parent directory of '{0}' is '{1}'", dis->Name,
 parentDir->Name );
   
   // Delete the parent directory.
   di->Delete( true );
}

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

public class MoveToTest
{
    public static void main(String[]
 args)
    {
        // Make a reference to a directory.
        DirectoryInfo di = new DirectoryInfo("TempDir");

        // Create the directory only if it does not already exist.
        if (di.get_Exists() == false) {
            di.Create();
        }

        // Create a subdirectory in the directory just created.
        DirectoryInfo dis = di.CreateSubdirectory("SubDir");

        // Get a reference to the parent directory of the 
        // subdirectory you just made.
        DirectoryInfo parentDir = dis.get_Parent();

        Console.WriteLine("The parent directory of '{0}' is '{1}'",
            dis.get_Name(), parentDir.get_Name());

        // Delete the parent directory.
        di.Delete(true);
    } //main
} //MoveToTest
import System;
import System.IO;

public class MoveToTest {
    public static function
 Main() {

        // Make a reference to a directory.
        var di : DirectoryInfo = new DirectoryInfo("TempDir");

        // Create the directory only if it does not already exist.
        if (di.Exists == false)
            di.Create();

        // Create a subdirectory in the directory just created.
        var dis : DirectoryInfo = di.CreateSubdirectory("SubDir");

        // Get a reference to the parent directory of the subdirectory
 you just made.
        var parentDir : DirectoryInfo = dis.Parent;

        Console.WriteLine("The parent directory of '{0}' is '{1}'", dis.Name,
 parentDir.Name);

        // Delete the parent directory.
        di.Delete(true);
    }
}
MoveToTest.Main();
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS