|
-
Mar 24th, 2005, 07:42 PM
#1
Thread Starter
Hyperactive Member
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:
Private Sub Command1_Click()
Dim i As Integer
ProgressBar1.min = 0
'ProgressBar1.Max = 100
ProgressBar1.Value = 0
ProgressBar1.Scrolling = ccScrollingSmooth
Dim strFile() As String, strPath As String
Dim n As Long, nCount As Long
On Error Resume Next
With CommonDialog1
CommonDialog1.Filter = "MP3 Files|*.mp3" 'Only Show MP3 type files in folder
.Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNLongNames
.CancelError = True
.InitDir = "C:\"
.DialogTitle = "Select File To Add To Playlist"
.ShowOpen
If Err.Number <> cdlCancel Then
strFile = Split(.FileName, vbNullChar)
nCount = UBound(strFile)
If nCount = 0 Then
'Only one file is selected so split up the path and the filename
ReDim strFile(1)
strFile(0) = Left$(.FileName, InStrRev(.FileName, "\"))
strFile(1) = Mid$(.FileName, InStrRev(.FileName, "\") + 1)
nCount = 1
End If
strPath = strFile(0)
If Right$(strPath, 1) <> "\" Then
strPath = strPath & "\"
End If
ProgressBar1.Max = nCount
For n = 1 To nCount
If Len(Dir(FAVORITES_FOLDER & strFile(n))) = 0 Then
FileCopy strPath & strFile(n), FAVORITES_FOLDER & strFile(n)
End If
ProgressBar1.Value = n
ProgressBar1.Refresh
Next
End If
End With
End Sub
thanks
R
Last edited by robvr6; Mar 25th, 2005 at 10:03 AM.
-
Mar 24th, 2005, 11:22 PM
#2
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:
With CommonDialog1
.Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNLongNames
.MaxFileSize = 32767
'...the rest of the code...
-
Mar 25th, 2005, 10:02 AM
#3
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|