Your code fails because you iterate the sub folders, and only in the loop perform the check.
Here is a custom function I have to return plain array of sub folder names of a given root folder:
'GetSubFolders: gets absolute path of a folder and returns array of its sub folders.
'In case given path is not a valid existing folder path, empty array is returned. (no error check)
Function GetSubFolders(strAbsoluteFolderPath)
Dim objFSO, objFolder, arrSubFolders()
Dim oCurrentSubFolder
ReDim arrSubFolders(-1)
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strAbsoluteFolderPath) Then
Set objFolder = objFSO.GetFolder(strAbsoluteFolderPath)
For Each oCurrentSubFolder In objFolder.SubFolders
ReDim Preserve arrSubFolders(UBound(arrSubFolders) + 1)
arrSubFolders(UBound(arrSubFolders)) = oCurrentSubFolder.Name
Next
Set objFolder = Nothing
End If
Set objFSO = Nothing
GetSubFolders = arrSubFolders
End Function
Usage in your case is as simple as:
Dim arrSubFolders
arrSubFolders = GetSubFolders(Server.MapPath("../newsletterDB"))
If UBound(arrSubFolders)>=0 Then
Response.write("<input type = ""radio"" name=""group1"" value=""" & arrSubFolders(0) & """>" & arrSubFolders(0) & "<br>")
Else
response.write " Please upload any e-Mag first !"
End If
Erase arrSubFolders