2011-05-10 4 views
0

어떻게하면 다음 디렉토리의 상위 디렉토리를 얻을 수 있습니까?상위 디렉토리에 액세스

string rootFolder = System.Web.HttpContext.Current.Server.MapPath(APP_PATH); 
+0

부모 물리적 폴더를 의미합니까? – mohammedn

답변

2

new DirectoryInfo(rootFolder).Parent.FullName 또는 Directory.GetParent(rootFolder).FullName

+0

어떤 이유인지, GetParent는 나에게 똑같은 폴더를 제공합니다 – user517406

+0

이것은 내가 원하는 폴더를 얻었습니다 : string str = Directory.GetParent (rootFolder) .Parent.FullName; – user517406

+0

이 경우 가독성을 위해'new DirectoryInfo (rootFolder) .Parent.FullName'을 사용할 수 있습니다. –

관련 문제