Hi Guys,

Im more familiar with coding in C# ... can someone please help me to convert the line highlighted below into VB.NET

Much appreciated

private int file_count = 0;
///
/// Get the file count of a given directory recursively.
///
public void GetDirectoryFileCount(string dir)
{
dir = dir + @”\”;
//get all the directories and files inside a directory
String[] all_files=Directory.GetFileSystemEntries(dir);
//loop through all items
[B]foreach(string file in all_files)[/B]
{
//check to see if the file is a directory if not increment the count
if(Directory.Exists(file))
{
//recursive call
GetDirectoryFileCount(file);
}
else
{
//increment file count
file_count++;
}
}
}

If you declare file in advance it's just

Dim file As string

followed with

For Each file in all_files

At least that's how I normally do it

"For Each liListItem In ddlAssigned.Items" is how I've done it

That's your codes or get from internet?

Private file_count As Integer = 0
Public Sub GetDirectoryFileCount(ByVal dir As String)
  dir = dir & ”\”
  Dim all_files() As String=Directory.GetFileSystemEntries(dir)
  For Each file As String In all_files
    If Directory.Exists(file) Then
      GetDirectoryFileCount(file)
    Else
      file_count += 1
    End If
  Next file
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.