0
어떻게 경로를 분할하여 값 CustomCompanyNames를 얻을 수 있습니까?경로에서 하위 디렉토리 가져 오기
는어떻게 값을 얻을 수 있습니다 C:\Project\v4.0\Tool\Custom\CustomCompanyNames\Template\bin\file\file.xml
? 특정 파일에 대해 "템플릿"디렉토리의 상위 디렉토리를 얻고 싶은 경우에
어떻게 경로를 분할하여 값 CustomCompanyNames를 얻을 수 있습니까?경로에서 하위 디렉토리 가져 오기
는어떻게 값을 얻을 수 있습니다 C:\Project\v4.0\Tool\Custom\CustomCompanyNames\Template\bin\file\file.xml
? 특정 파일에 대해 "템플릿"디렉토리의 상위 디렉토리를 얻고 싶은 경우에
이 시도 할 수 있습니다 :
이public string GetTemplateDirectoryParentName(string filePath)
{
FileInfo fileInfo = new FileInfo(filePath);
DirectoryInfo directoryInfo = fileInfo.Directory;
while(directoryInfo.Name != "Tempalte")
{
direcotryInfo = direcotryInfo.Parent;
}
return direcotryInfo.Parent.Name;
}
당신은 그것을 다른 방법으로 할 수있는 "사용자 지정"디렉토리의 하위 디렉토리를 얻어서 :
public string GetTemplateDirectoryParentName(string filePath)
{
FileInfo fileInfo = new FileInfo(filePath);
DirectoryInfo directoryInfo = fileInfo.Directory;
while(directoryInfo.Parent.Name != "Custom")
{
direcotryInfo = direcotryInfo.Parent;
}
return direcotryInfo.Name;
}
감사합니다. – mimu1011
참조 string.Split –
Thx, 경로를 분할하는 방법을 찾고 있습니다. Value CustomCompanyNames를 얻기위한 패턴을 알고 있습니까? – mimu1011
http://stackoverflow.com/questions/3736462/getting-the-folder-name-from-a-path – dymanoid