BUG: Drag From FileListBox Includes Extra Backslash (183906)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q183906 SYMPTOMS
If a file is dragged from the FileListBox control, and that file is located
in the root directory, Visual Basic includes an extra backslash (\) in the
file path. This may cause one of the following errors on Windows 95, Windows 98, or Windows Me:
Cannot copy file. File System Error (1026)
-or-
Cannot copy <filename>. Cannot find the specified file. Make sure you
specify the correct path and filename.
While no error occurs under Windows NT or Windows 2000, the erroneous backslash is still present.
RESOLUTION
As a workaround, add the following code to your form. The code will
intercept the Drag operation and remove the extra backslash character. This
code assumes that the name of the FileListBox is File1:
Private Sub File1_OLEStartDrag(Data As DataObject, _
AllowedEffects As Long)
Dim FileNames As New Collection
Dim vFn As Variant
'Retrieve current set of files from the file control
For Each vFn In Data.Files
FileNames.Add vFn
Next vFn
'Clear the list in the data object, and add the corrected files back
Data.Files.Clear
For Each vFn In FileNames
Data.Files.Add RemoveExtraBackslash(vFn)
Next vFn
End Sub
Private Function RemoveExtraBackslash(ByVal str$) As String
While True
Dim i%
i = InStr(str, "\\")
If i > 0 Then
str = Left$(str, i - 1) & Mid$(str, i + 1)
Else
RemoveExtraBackslash = str
Exit Function
End If
Wend
End Function
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products
listed at the beginning of this article. We are researching this
bug and will post new information here in the Microsoft Knowledge
Base as it becomes available.
Modification Type: | Major | Last Reviewed: | 5/12/2003 |
---|
Keywords: | kbBug kbControl kbCtrl kbpending KB183906 |
---|
|