c# to VB.Net

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 83
Reputation: Elmo_loves_you is an unknown quantity at this point 
Solved Threads: 0
Elmo_loves_you's Avatar
Elmo_loves_you Elmo_loves_you is offline Offline
Junior Poster in Training

c# to VB.Net

 
0
  #1
Sep 22nd, 2008
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
foreach(string file in all_files)
{
//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++;
}
}
}
Michelle (Junior Developer)
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

Re: c# to VB.Net

 
0
  #2
Sep 22nd, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: c# to VB.Net

 
0
  #3
Sep 22nd, 2008
That's your codes or get from internet?
  1. Private file_count As Integer = 0
  2. Public Sub GetDirectoryFileCount(ByVal dir As String)
  3. dir = dir & ”\”
  4. Dim all_files() As String=Directory.GetFileSystemEntries(dir)
  5. For Each file As String In all_files
  6. If Directory.Exists(file) Then
  7. GetDirectoryFileCount(file)
  8. Else
  9. file_count += 1
  10. End If
  11. Next file
  12. End Sub
Last edited by Jx_Man; Sep 22nd, 2008 at 12:43 pm.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC