开发者

How to store directory in variables

I 开发者_运维知识库am using the following code to search for a specific file with .doc extension. How can I get this info into a variable to be used later?

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 {}.


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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜