?
Solved

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

Posted on 2004-04-07
8
Medium Priority
?
457 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 17

Accepted Solution

by:
zzzzzooc earned 1000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month8 days, 18 hours left to enroll

764 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