문제

Ant에 사용 된 것과 같은 복잡한 패턴을 사용하여 디렉토리에서 파일 또는 디렉토리를 가져 오기위한 C# 라이브러리를 찾고 있습니다.

  • dir1/dir2/**/SVN/* -> DIR1/DIR2 아래 디렉토리 트리의 어느 곳에 위치한 SVN 디렉토리의 모든 파일과 일치합니다.
  • **/test/** -> 파일 이름으로 테스트를 포함하여 경로에 테스트 요소가있는 모든 파일과 일치합니다.
  • ...

직접 코딩해야합니까? 내가 Nant에서 원하는 것을 추출합니까? 또는이 라이브러리가 존재하고 내 Google 기술이 짜증납니다.

Directory.GetFiles(String path, String searchPattern) 디렉토리 패턴을 처리하지 않습니다 ndepend.helpers.FileDirectoryPath 둘 다 (그건 그렇고 경로 조작을위한 훌륭한 도서관입니다)

도움이 되었습니까?

해결책

Coding it yourself wouldnt be that hard.

Just use a correctly formulated regular expression with System.IO methods to build the full path

다른 팁

Are you comfortable with defining "*" as "anything but slash" and "**" as "anything at all"? If so, the regex conversion seems straightforward.

*   -> [^\/]*
**  -> .*

Then it's a matter of recursively enumerating all files, and checking if their paths match the regex.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top