Results 1 to 3 of 3

Thread: Adding large number of files [RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Resolved Adding large number of files [RESOLVED]

    Back again. I want to add files to a directory but at present can only add about five and dont know why.

    here is the code Im using

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3.     Dim i As Integer
    4.  
    5.     ProgressBar1.min = 0
    6.     'ProgressBar1.Max = 100
    7.     ProgressBar1.Value = 0
    8.     ProgressBar1.Scrolling = ccScrollingSmooth
    9.  
    10.     Dim strFile() As String, strPath As String
    11.     Dim n As Long, nCount As Long
    12.     On Error Resume Next
    13.     With CommonDialog1
    14.         CommonDialog1.Filter = "MP3 Files|*.mp3"       'Only Show MP3 type files in folder
    15.  
    16.         .Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNLongNames
    17.         .CancelError = True
    18.         .InitDir = "C:\"
    19.         .DialogTitle = "Select File To Add To Playlist"
    20.      
    21.         .ShowOpen
    22.         If Err.Number <> cdlCancel Then
    23.             strFile = Split(.FileName, vbNullChar)
    24.             nCount = UBound(strFile)
    25.             If nCount = 0 Then
    26.                 'Only one file is selected so split up the path and the filename
    27.                 ReDim strFile(1)
    28.                 strFile(0) = Left$(.FileName, InStrRev(.FileName, "\"))
    29.                 strFile(1) = Mid$(.FileName, InStrRev(.FileName, "\") + 1)
    30.                 nCount = 1
    31.             End If
    32.             strPath = strFile(0)
    33.             If Right$(strPath, 1) <> "\" Then
    34.                 strPath = strPath & "\"
    35.             End If
    36.             ProgressBar1.Max = nCount
    37.             For n = 1 To nCount
    38.     If Len(Dir(FAVORITES_FOLDER & strFile(n))) = 0 Then
    39.         FileCopy strPath & strFile(n), FAVORITES_FOLDER & strFile(n)
    40.     End If
    41.     ProgressBar1.Value = n
    42.     ProgressBar1.Refresh
    43. Next
    44.         End If
    45.     End With
    46. End Sub

    thanks
    R
    Last edited by robvr6; Mar 25th, 2005 at 10:03 AM.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Adding large number of files

    The CommonDialog control has a MaxFileSize property, despite its name it actually is the maximum length of the string returned by the FileName property. It defaults to 256, so the FileName property can only contain 256 characters unless you change the MaxFileSize property. This property is cast as an integer which means that the largest number you can assign to it is 32767 but that would be pretty many file names. So change your code slightly
    VB Code:
    1. With CommonDialog1
    2.     .Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNLongNames
    3.     .MaxFileSize = 32767
    4.     '...the rest of the code...

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    Re: Adding large number of files

    SORTED.
    Thanks very much Joacim

    Rob

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