2012-03-30 4 views
0

실제로이 목록은 프로젝트의 이름을 문자열로 추가하는 "디렉토리"목록입니다.목록에서 문자열 만들기

인덱스 0 oldProjectName 프로젝트 1

인덱스 1 oldProjectName 프로젝트 2

내가 디렉토리 경로를 만들려면/프로젝트 1/프로젝트 2의 /와 같은 문자열을 만들려고하지만 난 문제 때이 그것을 만들어라. 결과는/Project1의/프로젝트 2/프로젝트 2/항상 왜

foreach (string s in Directory) 
      {      
       DirectoryPath = '/' + DirectoryPath + '/' + thePreviousItem.oldProjectName + '/'; 
      } 

나는

+4

당신은에's'를 사용하지 않는 귀하의 루프 ... –

답변

1
try 

DirectoryPath="" 
foreach (string s in Directory) 
     { 

      DirectoryPath = DirectoryPath.equals("")? s : '/' + DirectoryPath + '/' + s + '/'; 
     } 
2

... 궁금 왜 안 :

DirectoryPath = string.Join(@"/", Directory); 
+0

그래, 왜 안돼 ?? – CoffeeRain