DOCUMENT:Q183906 26-APR-1998 [vbwin] TITLE :BUG: Drag From FileListBox Includes Extra Backslash PRODUCT :Microsoft Visual Basic for Windows PROD/VER:WINDOWS:5.0 OPER/SYS:WINDOWS KEYWORDS:vb5all ====================================================================== --------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 5.0 --------------------------------------------------------------------- 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: Cannot copy file. File System Error (1026) -or- Cannot copy . Cannot find the specified file. Make sure you specify the correct path and filename. While no error occurs under Windows NT, 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. MORE INFORMATION ================ Steps to Reproduce Behavior --------------------------- 1. Start a new Standard EXE project in Visual Basic. Form1 is created by default. 2. Add a FileListBox and a DirListBox to Form1. 3. Add the following code to Form1: Private Sub Dir1_Change() File1.Path = Dir1.Path End Sub 4. Change OLEDragMode property of the FileListBox to 1-Automatic. 5. Start the program and change the path of the DirListBox to C:\. 6. Start Windows Explorer. 7. If you are running Windows 95, drag one of the files from the FileListBox to any directory in Windows Explorer. You should see an error dialog as described earlier. 8. Drag one of the files from the FileListBox to the Start...Run dialog window. You should see the incorrect path with the extra backslash. 9. Copy the workaround code from the RESOLUTION section into your project and run it again. Drag one of the files from the FileListBox to the Start...Run dialog window. You should see the correct path displayed. Additional query words: back slash listbox file list box ====================================================================== Keywords : vb5all Version : WINDOWS:5.0 Platform : WINDOWS Issue type : kbbug Solution Type : kbpending ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 1998.