G
Guest
Apparently VB.Net has a new behaviour for the DIR function and I quote: -
==================================================================================================
In Visual Basic 6.0, the Dir function was used to return the name of a
file, folder, or directory. The "." and ".." strings could be used in the
path argument to represent the current directory or the encompassing
directory, respectively.
In Visual Basic .NET, the Dir function is essentially the same, but the
"." and ".." syntax has a different behavior.
What to do next
Code that returned files or directories was often written with the
assumption that the "." and ".." would be returned as the first two entries;
this
is no longer true in Visual Basic .NET. Because of the difference in
behavior, the upgraded code may not return the first two files or
directories.
=================================================================================================
The code we have looks for the . or .. and will change the icon and also
provide the facility to go back to the upper level. Does anyone know how we
can alter the code in .Net to allow for the new behaviour.
Our code is as follows: -
strFolder = Dir(strBase & "*.*", FileAttribute.Directory)
Do While strFolder > ""
If GetAttr(strBase & strFolder) = FileAttribute.Directory And
strFolder <> "." Then
If mintLevel > 0 Or strFolder <> ".." Then
itmFold = lsvFolders.ListItems.Add(, , strFolder)
If strFolder = ".." Then
itmFold.Icon = "Up"
Else
itmFold.Icon = "Closed"
End If
End If
End If
'UPGRADE_WARNING: Dir has a new behavior. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1041"'
strFolder = Dir()
Loop
===========================================================
Thanks Scott
==================================================================================================
In Visual Basic 6.0, the Dir function was used to return the name of a
file, folder, or directory. The "." and ".." strings could be used in the
path argument to represent the current directory or the encompassing
directory, respectively.
In Visual Basic .NET, the Dir function is essentially the same, but the
"." and ".." syntax has a different behavior.
What to do next
Code that returned files or directories was often written with the
assumption that the "." and ".." would be returned as the first two entries;
this
is no longer true in Visual Basic .NET. Because of the difference in
behavior, the upgraded code may not return the first two files or
directories.
=================================================================================================
The code we have looks for the . or .. and will change the icon and also
provide the facility to go back to the upper level. Does anyone know how we
can alter the code in .Net to allow for the new behaviour.
Our code is as follows: -
strFolder = Dir(strBase & "*.*", FileAttribute.Directory)
Do While strFolder > ""
If GetAttr(strBase & strFolder) = FileAttribute.Directory And
strFolder <> "." Then
If mintLevel > 0 Or strFolder <> ".." Then
itmFold = lsvFolders.ListItems.Add(, , strFolder)
If strFolder = ".." Then
itmFold.Icon = "Up"
Else
itmFold.Icon = "Closed"
End If
End If
End If
'UPGRADE_WARNING: Dir has a new behavior. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1041"'
strFolder = Dir()
Loop
===========================================================
Thanks Scott