Results 1 to 4 of 4

Thread: bad file name error #52

  1. #1

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Resolved bad file name error #52

    This function gathers all the drive letters on a USB drive. It is reporting a bad File Name at Line 90 anyone know why ?

    Code:
    Function BackUpBidFoldersDrive() As String
                Dim UsbDriverLetters() As String
                Dim DriveLetterToUse As String
                Dim counter As Integer
                Dim i As Integer
                Dim UsbDriveLetter As String
                Dim TmpDriveLetter As String
                Dim CdFlashDriveLetter As String
                Dim freespace As Double 'Long
                Dim MostSpace As Double
    30            On Error GoTo e
          
    40           counter = 0
    
    50            For i = 65 To 90
    60              If DriveType(Chr$(i)) = "removeable" Then
    70                    If Chr$(i) <> "A" Then 'A shows as removal also
                              counter = counter + 1
    80                        TmpDriveLetter = Chr$(i)
    90                           ReDim Preserve UsbDriverLetters(counter + 1) 'error here
                                 UsbDriverLetters(counter) = Chr$(i) & ":\"
                           
                       End If
                   End If
                Next i
    Last edited by isnoend07; Apr 30th, 2010 at 11:45 AM. Reason: unmarked resolved
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  2. #2
    Addicted Member Xiphias3's Avatar
    Join Date
    Jan 2009
    Location
    Clarendon, Jamaica
    Posts
    188

    Re: bad file name error #52

    No idea cuz i dont see anything wrong. Have you tried restarting the IDE?
    vb Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetLogicalDriveStrings Lib "kernel32.dll" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
    4. Private Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
    5. Private Const DRIVE_REMOVABLE As Long = 2
    6.  
    7. Private Sub Form_Load()
    8.     Dim szDrivesBuff As String, lRet As Long, szDrives() As String, nIndx As Integer, nDrvIndex As Integer, szRemDrives() As String
    9.    
    10.     nDrvIndex = 0
    11.     szDrivesBuff = Space(255)
    12.     lRet = GetLogicalDriveStrings(Len(szDrivesBuff), szDrivesBuff)
    13.     szDrivesBuff = Left(szDrivesBuff, lRet)
    14.     szDrives() = Split(szDrivesBuff, Chr(0))
    15.     For nIndx = 0 To UBound(szDrives()) Step 1
    16.         If (GetDriveType(szDrives(nIndx)) = DRIVE_REMOVABLE) Then
    17.             If (szDrives(nIndx) <> "A:\") Then
    18.                 ReDim Preserve szRemDrives(nDrvIndex)
    19.                 szRemDrives(nDrvIndex) = szDrives(nIndx)
    20.                 nDrvIndex = nDrvIndex + 1
    21.             End If
    22.         End If
    23.     Next nIndx
    24. End Sub

  3. #3

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: bad file name error #52

    Found it. It was in my drive type
    replaced this
    sDriveName = GetDriveType(sDrive & ":\")
    with
    sDriveName = sDrive & ":\"
    This was incorrect as a solutation
    How do i unresolve this question ?
    Last edited by isnoend07; Apr 30th, 2010 at 11:30 AM.
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  4. #4

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: bad file name error #52

    Just noticed that the function has no line number past 90, but that does not solve the problem, the erorr still happens just not on that line
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width