Consider the case where we have a folder containing text files temp.txt, tem.txt, temp1.txt, temp2.txt.
In the above text file list if we want to get path for the files using “temp*.txt” wild card, GetFiles (System.IO.Directory) method can be used.
The above code will retrieve paths of temp.txt, temp1.txt, and temp2.txt files but not for tem.txt file.
Dim inFile,oColFilesList,oArrayList,oDI
Set oArrayList=DotNetFactory.CreateInstance("System.Collections.ArrayList","")
Set oDI=DotNetFactory.CreateInstance("System.IO.Directory","mscorlib")
Set oColFilesList=oArrayList.Adapter(oDI.GetFiles("C:\Files List","temp*.txt"))
For inFile=0 to Cint(oColFilesList.Count)-1
Msgbox oColFilesList(inFile)
Next
Set oArrayList=Nothing
Set oDI=Nothing
Set oColFilesList=Nothing
No comments:
Post a Comment