DirectoryInfo.CreateSubdirectory 메서드

정의

지정된 경로에 하위 디렉터리 또는 하위 디렉터리를 만듭니다. 지정된 경로는 클래스의 DirectoryInfo 이 인스턴스를 기준으로 할 수 있습니다.

오버로드

Name Description
CreateSubdirectory(String)

지정된 경로에 하위 디렉터리 또는 하위 디렉터리를 만듭니다. 지정된 경로는 클래스의 DirectoryInfo 이 인스턴스를 기준으로 할 수 있습니다.

CreateSubdirectory(String, DirectorySecurity)

지정된 보안을 사용하여 지정된 경로에 하위 디렉터리 또는 하위 디렉터리를 만듭니다. 지정된 경로는 클래스의 DirectoryInfo 이 인스턴스를 기준으로 할 수 있습니다.

CreateSubdirectory(String)

지정된 경로에 하위 디렉터리 또는 하위 디렉터리를 만듭니다. 지정된 경로는 클래스의 DirectoryInfo 이 인스턴스를 기준으로 할 수 있습니다.

public:
 System::IO::DirectoryInfo ^ CreateSubdirectory(System::String ^ path);
public System.IO.DirectoryInfo CreateSubdirectory(string path);
member this.CreateSubdirectory : string -> System.IO.DirectoryInfo
Public Function CreateSubdirectory (path As String) As DirectoryInfo

매개 변수

path
String

지정된 경로입니다. 다른 디스크 볼륨 또는 UNC(유니버설 명명 규칙) 이름이 될 수 없습니다.

반품

에 지정된 마지막 디렉터리입니다 path.

예외

path 는 유효한 파일 경로를 지정하지 않거나 잘못된 DirectoryInfo 문자를 포함합니다.

pathnull입니다.

지정된 경로가 잘못되었습니다(예: 매핑되지 않은 드라이브에 있는 경우).

하위 디렉터리를 만들 수 없습니다.

-또는-

파일에 이미 지정한 path이름이 있습니다.

지정된 경로, 파일 이름 또는 둘 다 시스템 정의 최대 길이를 초과합니다.

호출자에게 디렉터리를 만들 수 있는 코드 액세스 권한이 없습니다.

-또는-

호출자에게 반환 DirectoryInfo 된 개체에서 설명하는 디렉터리를 읽을 수 있는 코드 액세스 권한이 없습니다. 이 문제는 매개 변수가 path 기존 디렉터리를 설명할 때 발생할 수 있습니다.

path 에는 드라이브 레이블의 일부가 아닌 콜론 문자(:)("C:\")가 포함됩니다.

예제

다음 예제에서는 하위 디렉터리를 만드는 방법을 보여 줍니다. 이 예제에서는 만든 디렉터리를 만든 후에 제거합니다. 따라서 이 샘플을 테스트하려면 코드에서 삭제 줄을 주석 처리합니다.

using System;
using System.IO;

public class CreateSubTest
{
    public static void Main()
    {
        // Create a reference to a directory.
        DirectoryInfo di = new 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");

        // Process that directory as required.
        // ...

        // Delete the subdirectory.
        dis.Delete(true);

        // Delete the directory.
        di.Delete(true);
    }
}
open System.IO

// Create a reference to a directory.
let di = DirectoryInfo "TempDir"

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

// Create a subdirectory in the directory just created.
let dis = di.CreateSubdirectory "SubDir"

// Process that directory as required.
// ...

// Delete the subdirectory.
dis.Delete true

// Delete the directory.
di.Delete true
Imports System.IO

Public Class CreateSubTest

    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")

        ' Process that directory as required.
        ' ...

        ' Delete the subdirectory.
        dis.Delete(True)

        ' Delete the directory.
        di.Delete(True)
    End Sub
End Class

설명

일부 path 부분이 유효하지 않은 한 지정된 path 모든 디렉터리를 만듭니다. 매개 변수는 path 파일 경로가 아닌 디렉터리 경로를 지정합니다. 하위 디렉터리가 이미 있는 경우 이 메서드는 아무 작업도 수행하지 않습니다.

일반적인 I/O 작업 목록은 일반적인 I/O 작업을 참조하세요.

추가 정보

적용 대상

CreateSubdirectory(String, DirectorySecurity)

지정된 보안을 사용하여 지정된 경로에 하위 디렉터리 또는 하위 디렉터리를 만듭니다. 지정된 경로는 클래스의 DirectoryInfo 이 인스턴스를 기준으로 할 수 있습니다.

public:
 System::IO::DirectoryInfo ^ CreateSubdirectory(System::String ^ path, System::Security::AccessControl::DirectorySecurity ^ directorySecurity);
public System.IO.DirectoryInfo CreateSubdirectory(string path, System.Security.AccessControl.DirectorySecurity directorySecurity);
member this.CreateSubdirectory : string * System.Security.AccessControl.DirectorySecurity -> System.IO.DirectoryInfo
Public Function CreateSubdirectory (path As String, directorySecurity As DirectorySecurity) As DirectoryInfo

매개 변수

path
String

지정된 경로입니다. 다른 디스크 볼륨 또는 UNC(유니버설 명명 규칙) 이름이 될 수 없습니다.

directorySecurity
DirectorySecurity

적용할 보안입니다.

반품

에 지정된 마지막 디렉터리입니다 path.

예외

path 는 유효한 파일 경로를 지정하지 않거나 잘못된 DirectoryInfo 문자를 포함합니다.

pathnull입니다.

지정된 경로가 잘못되었습니다(예: 매핑되지 않은 드라이브에 있는 경우).

하위 디렉터리를 만들 수 없습니다.

-또는-

파일 또는 디렉터리에 이미 지정한 path이름이 있습니다.

지정된 경로, 파일 이름 또는 둘 다 시스템 정의 최대 길이를 초과합니다.

호출자에게 디렉터리를 만들 수 있는 코드 액세스 권한이 없습니다.

-또는-

호출자에게 반환 DirectoryInfo 된 개체에서 설명하는 디렉터리를 읽을 수 있는 코드 액세스 권한이 없습니다. 이 문제는 매개 변수가 path 기존 디렉터리를 설명할 때 발생할 수 있습니다.

path 에는 드라이브 레이블의 일부가 아닌 콜론 문자(:)("C:\")가 포함됩니다.

설명

일부 path 부분이 유효하지 않은 한 지정된 path 모든 디렉터리를 만듭니다. 매개 변수는 path 파일 경로가 아닌 디렉터리 경로를 지정합니다. 하위 디렉터리가 이미 있는 경우 이 메서드는 아무 작업도 수행하지 않습니다.

일반적인 I/O 작업 목록은 일반적인 I/O 작업을 참조하세요.

적용 대상