|
-
Jul 27th, 2011, 03:29 PM
#1
Thread Starter
Addicted Member
if statement only choice
hi gurus
Here is my problem->
I have three folders that I need to check if they are empty or not, if one of them is empty, I would like to keep checking the other two, if they are not empty I want to do something and then check the other two, but not all the time all three will be empty or not empty there might be times where one folder has something and the other two not and so on. I just want to check a folder and if its empty go to the next one but if not do something and still g to the next one to check if it empty or not, an so on
what would be my best approach to solve this.
Nested If statement or is there a better way.
Thanks a bunch gurus
thanks a bunch
-
Jul 27th, 2011, 03:33 PM
#2
Re: if statement only choice
Code:
Dim folders = New String() {"C:\test\folder1", _
"C:\test\folder2", _
"C:\test\folder3"}
For Each folder In folders
Dim directory = New IO.DirectoryInfo(folder)
Dim files = directory.GetFiles()
If files.Length > 0 Then
'//not empty, process files
End If
Next
-
Jul 27th, 2011, 03:35 PM
#3
Re: if statement only choice
you just need to check all 3 folders for files sequentially:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If IO.Directory.GetFiles("folder1").Count > 0 Then
End If
If IO.Directory.GetFiles("folder2").Count > 0 Then
End If
If IO.Directory.GetFiles("folder3").Count > 0 Then
End If
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 27th, 2011, 08:46 PM
#4
Thread Starter
Addicted Member
Re: if statement only choice
WoW gurus
Thanks a bunch , I think I was going in the wrong direction,thanks again
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|