Group,

I'm counting the number of files in a folder using the following code:

Dim counter = My.Computer.FileSystem.GetFiles(folderName)

This produces a value that doesn't appear to be either a string or an integer. Would you know how to convert this value into an integer that can be used?

Don

GetFiles returns an array. Something like this should work:

Dim counter = My.Computer.FileSystem.GetFiles(folderName).Length

One thing to keep in mind. If you plan on using the array of filenames later,generally, one would create an array to hold the names and use the length property from it:

Dim filenames = My.Computer.FileSystem.GetFiles(folderName)
Dim counter = filenames.Length

Another thing to keep in mind. FileSystem is VB specific. Many programmers tend to switch to the System.IO library, which is a CLR library and can be used in any of the .net languages.

Edited 1 Year Ago by tinstaafl

tinstaafl, thanks for the code and the tips. Most importantly, it worked perfectly!

Thanks for the help!

Don

This question has already been answered. Start a new discussion instead.