Mark, to some extent, I could understand what you have said.
Now you are saying that since the directory is actually of type
DirectoryInfo, it will assume it's not a directory & hence get <FILE>
appended to it. But since the directory is actually of type
DirectoryInfo, then why doesn't it assume that it's a DirectoryInfo
instead of assuming that it's not a directory?
Could you please explain me this point? Getting a bit confused....to be
honest...
Moreover, like the FileSystemInfo class is the base class for the
DirectoryInfo & FileInfo classes, which class is the base class for the
Directory & File classes?
Thanks
Mark Fitzpatrick wrote:
The answer is the FileSystemInfo class is a base for the DirectoryInfo and
FileInfo classes. It categorizes a directory as a DirectoryInfo and not a
Directory. So, since the directory is actually of type DirectoryInfo, then
it will assume it's not a directory and get the <fileappended to it.
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
<rn**@rediffmail.comwrote in message
news:11**********************@s80g2000cwa.googlegr oups.com...
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 <DIRwhereas 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?