[C# / .NET / WPF ] HttpServerUtility.MapPath(String) 메서드

728x90

https://learn.microsoft.com/ko-kr/dotnet/api/system.web.httpserverutility.mappath?view=netframework-4.8 

 

HttpServerUtility.MapPath(String) Method (System.Web)

Returns the physical file path that corresponds to the specified virtual path.

learn.microsoft.com

 

- 지정된 가상 경로에 해당하는 실제 파일 경로를 반환한다.

public class SampleClass
{
    public string GetFilePath()
    {
        return HttpContext.Current.Server.MapPath("/UploadedFiles");
    }
}

 

- 괄호안에 문자를 넣어주면 그게 가상경로가 된다. null인경우 현재 경로만 출력되어 나옴.

 

728x90

'C# > C# 개념' 카테고리의 다른 글

[C#] .getLength 메서드  (0) 2023.09.05