다음을 통해 공유


Environment.GetFolderPath 메서드

지정한 열거형으로 식별되는 시스템 관련 폴더에 대한 경로를 가져옵니다.

네임스페이스: System
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public Shared Function GetFolderPath ( _
    folder As SpecialFolder _
) As String
‘사용 방법
Dim folder As SpecialFolder
Dim returnValue As String

returnValue = Environment.GetFolderPath(folder)
public static string GetFolderPath (
    SpecialFolder folder
)
public:
static String^ GetFolderPath (
    SpecialFolder folder
)
public static String GetFolderPath (
    SpecialFolder folder
)
public static function GetFolderPath (
    folder : SpecialFolder
) : String

매개 변수

  • folder
    시스템 관련 폴더를 식별하는 열거형 상수입니다.

반환 값

해당 폴더가 실제로 컴퓨터에 있으면 지정한 시스템 특수 폴더에 대한 경로이고, 그렇지 않으면 빈 문자열("")입니다. 운영 체제에서 폴더를 만들지 않았거나, 기존 폴더가 삭제되었거나, 폴더가 My Computer와 같이 실제 경로에 해당하지 않는 가상 디렉터리인 경우 해당 폴더는 실제로 존재하지 않습니다.

예외

예외 형식 조건

ArgumentException

folder가 System.Environment.SpecialFolder의 멤버가 아닌 경우

설명

이 메서드는 공용 정보에 액세스하는 데 사용될 수 있는 Program Files, Programs, System, Startup 등의 시스템 관련 폴더에 대한 경로를 검색합니다. 특수 폴더는 Windows를 설치할 때 기본적으로 시스템에서 설정하거나 사용자가 명시적으로 설정합니다.

folder 매개 변수는 검색할 특수 폴더를 지정하며, Environment.SpecialFolder 열거형에 있는 값 중 하나여야 합니다. 다른 값을 사용하면 예외가 throw됩니다.

특수 폴더에 대한 자세한 내용은 https://msdn.microsoft.com/library/en-us/shellcc/platform/Shell/reference/enums/csidl.asp에서 "CSIDL 값" 항목을 참조하십시오.

예제

' Sample for the Environment.GetFolderPath method
Imports System

Class Sample
   Public Shared Sub Main()
      Console.WriteLine()
      Console.WriteLine("GetFolderPath: {0}", Environment.GetFolderPath(Environment.SpecialFolder.System))
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'
'GetFolderPath: C:\WINNT\System32
'
// Sample for the Environment.GetFolderPath method
using System;

class Sample 
{
    public static void Main() 
    {
    Console.WriteLine();
    Console.WriteLine("GetFolderPath: {0}", 
                 Environment.GetFolderPath(Environment.SpecialFolder.System));
    }
}
/*
This example produces the following results:

GetFolderPath: C:\WINNT\System32
*/
// Sample for the Environment::GetFolderPath method
using namespace System;
int main()
{
   Console::WriteLine();
   Console::WriteLine( "GetFolderPath: {0}", Environment::GetFolderPath( Environment::SpecialFolder::System ) );
}

/*
This example produces the following results:

GetFolderPath: C:\WINNT\System32
*/

.NET Framework 보안

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0에서 지원

참고 항목

참조

Environment 클래스
Environment 멤버
System 네임스페이스