R
rn5a
Suppose I have the following code:
<script runat="server">
Sub Page_Load(.....)
Dim dInfo As DirectoryInfo
Dim fsi As FileSystemInfo
dInfo = New DirectoryInfo(Server.MapPath("Folder1"))
For Each fsi In dInfo.FileSystemInfo
If (fsi.GetType Is GetType(DirectoryInfo)) Then
Response.Write(fsi.Name & " <DIR><br>")
Else
Response.Write(fsi.Name & "<FILE><br>"
End If
Next
End Sub
</script>
Assume that the folder named 'Folder1' has only 1 directory & 10 files.
When the above code is executed, then items which are directories get
successfully appended with <DIR> whereas items which are files get
appended with <FILE>. No problems till here.
But if I replace the If condition shown above (the first line within
the For..Next loop) with the following If conditiom:
If (fsi.GetType Is GetType(Directory))
i.e. change the second operand from GetType(DirectoryInfo) to
GetType(Directory), then even the single directory existing in Folder1
gets appended with <FILE> & not with <DIR>.
Why so?
<script runat="server">
Sub Page_Load(.....)
Dim dInfo As DirectoryInfo
Dim fsi As FileSystemInfo
dInfo = New DirectoryInfo(Server.MapPath("Folder1"))
For Each fsi In dInfo.FileSystemInfo
If (fsi.GetType Is GetType(DirectoryInfo)) Then
Response.Write(fsi.Name & " <DIR><br>")
Else
Response.Write(fsi.Name & "<FILE><br>"
End If
Next
End Sub
</script>
Assume that the folder named 'Folder1' has only 1 directory & 10 files.
When the above code is executed, then items which are directories get
successfully appended with <DIR> whereas items which are files get
appended with <FILE>. No problems till here.
But if I replace the If condition shown above (the first line within
the For..Next loop) with the following If conditiom:
If (fsi.GetType Is GetType(Directory))
i.e. change the second operand from GetType(DirectoryInfo) to
GetType(Directory), then even the single directory existing in Folder1
gets appended with <FILE> & not with <DIR>.
Why so?