Solved

How to handle a large number of multiselected files with the VB6 common dialog?

Posted on 2004-04-07
8
440 Views
Last Modified: 2012-06-22
With multi-select, I use these settings for the VB6 common dialog
   
CommonDialog3.flags = cdlOFNAllowMultiselect Or cdlOFNFileMustExist Or cdlOFNExplorer
CommonDialog3.MaxFileSize = 10240

Beyond about 50 files selected, the files don't get identified. and therefore processeed. If I increase the MaxFileSize by a large amount, things freeze up.

Is there a workaround, or a way to warn the user not to select so many files, or am I missing something in my code?

From the experts, advice please!
0
Comment
Question by:Gordon_Atherley
8 Comments
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 10776655
I just selected about 600 with no problems using what you did (flags and maxfilesize). Using version 6.0 of the control (SP3)..

Private Sub Form_Load()
    Dim sSplit() As String
    CommonDialog1.Flags = cdlOFNAllowMultiselect Or cdlOFNFileMustExist Or cdlOFNExplorer
    CommonDialog1.MaxFileSize = 10240
    CommonDialog1.ShowOpen
    sSplit = Split(CommonDialog1.FileName, Chr(0))
    MsgBox UBound(sSplit)
End Sub
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 10777338
what sp you are using?

the max number for MaxFileSize is 32k
0
 

Author Comment

by:Gordon_Atherley
ID: 10779250
Thanks

SP 5

The 32k limit explains the problem I am running into. Are there any ways to effectively extend this or to warn users to limit their selections to a particular number? Even so, this would be a nuisance because it's not easy for the user to count the number of files selected.
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 250 total points
ID: 10780063
>> it's not easy for the user to count the number of files selected.

More so the length of all of the files selected. Your files must be really deep inside folders for you to go over 32k file length from under 50 selected files. I can select a couple thousand files in the system32 directory ok.

Anyways.. you could error-handle it and warn the users by the dialog title..  just an idea.. :P

Private Sub Command1_Click()
    On Error Resume Next
    Dim sArray() As String
    With CommonDialog1
        .DialogTitle = "Open file..."
        .Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer
        .InitDir = "c:\windows\system32\"
        .MaxFileSize = 3200
OpenAgain:
        Call .ShowOpen
        'May not be the same Err # for you..
        If Err.Number = 20476 Then
            .DialogTitle = "Too many files selected. Try again."
            .FileName = vbNullString
            Err.Clear
            GoTo OpenAgain
        Else
            If .FileName <> vbNullString Then
                sArray = Split(.FileName, vbNullChar)
                MsgBox UBound(sArray)
                .FileName = vbNullString
            End If
        End If
    End With
End Sub

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:redfordb
ID: 10782422
If the problem persists, create your own dialogue.
0
 

Author Comment

by:Gordon_Atherley
ID: 10782431
Thanks, zzzzzzooc, just what I was looking for.

The files are deep inside folders. Even so, I can't see how they create a file 32k in size. I've still to figure out that puzzle. But the two stage error handler solves the immediate problem.

0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 10787798
Oh.. it's not a matter of the length of one file. More so the combined length of all selected files being over 32k. It's still hard imagining the files being about 500+ characters long each though. :o
0
 

Author Comment

by:Gordon_Atherley
ID: 10787825
Agreed.
I'm going to explore further. If I find anything useful, I'll post it. :G
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now