For Each File As String In My.Computer.FileSystem.GetFiles(Line, FileIO.SearchOption.SearchTopLevelOnly, "*.txt|*.docx")
Next
is it right to OR extensions this way?
I just need to get the txt
and docx
files
For Each File As String In My.Computer.FileSystem.GetFiles(Line, FileIO.SearchOption.SearchTopLevelOnly, "*.txt|*.docx")
Next
is it right to OR extensions this way?
I just need to get the txt
and docx
files
If you look at this MSDN Forum Post it suggests that using an array to hold the file extensions like this will work. Using an Or statement like you have will give you an error.
Dim line As String = "C:\Temp"
Dim extension(1) As String
extension(0) = "*.txt"
extension(1) = "*.docx"
For Each File As String In My.Computer.FileSystem.GetFiles(Line, FileIO.SearchOption.SearchTopLevelOnly, extension)
Next
Dim extension As New List(Of String)
extension.Add("*.avi")
extension.Add("*.mkv")
extension.Add("*.wmv")
extension.Add("*.mp4")
For Each F In My.Computer.FileSystem.GetFiles("c:\yourPath", FileIO.SearchOption.SearchAllSubDirectories, extension.ToArray)
' do it
next