Solved

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

Posted on 2004-04-07
8
453 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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
 
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

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…
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…

707 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