Directory.GetFiles
및 "abc"및 "xyz"라는 파일 제외 방법은 무엇입니까?Directory.GetFiles (strFolderPath) 제외 특정 파일 이름 VB.NET
기본적으로 모든 파일이 있고 특정 파일 그룹을 하나의 부서로 보내야하고 "abc"및 "xyz"파일을 다른 곳으로 보내야하는 디렉터리가 있습니까? 순간
나는이 작업을 수행 :
'Standard Documents
Dim strAttachments As List(Of String) = New List(Of String)
strAttachments.AddRange(Directory.GetFiles(GlobalVariables.strFolderPath))
나는 동일한 기능을하지만, 파일을 제외이 필요하고 다른 주소로 파일을 포함 위와 비슷한 명령을한다.
건배 ,,
제임스
UPDATE
Dim exclude = {"ATS_Declaration"}
Dim myFiles = From fn In Directory.EnumerateFiles(GlobalVariables.strFolderPath)
Where Not exclude.Contains(Path.GetFileNameWithoutExtension(fn), StringComparer.InvariantCultureIgnoreCase)
Dim strAttachments As List(Of String) = New List(Of String)(myFiles)
가능한 복제본 [여러 기준에 따라 Directory.EnumerateFiles에서 파일 제외] (http://stackoverflow.com/questions/27285113/exclude-files-from-directory-enumeratefiles-based-on-multiple-criteria) – Plutonix
왜 strAttachments를 반복하고 나중에 두 개의 목록을 만들지 않습니까? – WeSt