Solved

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

Posted on 2004-04-07
8
439 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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

20 Experts available now in Live!

Get 1:1 Help Now