I am using following code to search a specific file with .doc extension. How can I get this info into a variable to be used later. Thanks
Dim di As New DirectoryInfo("d:\")
Dim files() As FileInfo = di.GetFiles("*.doc", SearchOption.AllDirectories)
I am using following code to search a specific file with .doc extension. How can I get this info into a variable to be used later. Thanks
Dim di As New DirectoryInfo("d:\")
Dim files() As FileInfo = di.GetFiles("*.doc", SearchOption.AllDirectories)
You already do have the info, in your files() array.
You can then use files() array to get a count of matches files.Length
, or iterate through the matching files foreach file as FileInfo in files {}
.
Not sure what the issue is, but the files
variable in your code sample already contains this information.
This line:
Dim files() As FileInfo = di.GetFiles("*.doc", SearchOption.AllDirectories)
Gets the file information and assigns it to the files()
array. This can now be used as it contains the information returned by the GetFiles
method.
From the code you've written, you've already got all the files .doc
files in the files()
array.
What exactly do you want to do?