Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Add Limit of Multiple File Upload using Common Dialog?

Status
Not open for further replies.

gryff15

Programmer
Sep 21, 2016
47
PH
I found this code but I found out that it only gets up to 35 filenames. Selecting more than that results to only one record with a corrupted square character. I need to be able to select at least 1000 files.
Code:
WITH THISFORM._COMDLG1
    .ClearFilters() && Clear filters in case in loop
    .lAllowMultiSelect = .T. && Enable multiple file selection
    .cFileName = [] && Do not set an initial file name
    .cInitialDirectory = [C:\My Documents] && Start folder
    .cTitlebarText = [Select multiple files] && Dialog titlebar text
    .aFilterList[1,1] = [Image Files (bmp,gif,jpg)] && First half of filter list
    .aFilterList[1,2] = [*.bmp;*.gif;*.jpg;*.jpeg] && Second half of filter list
    * Should you want additional filters you can add them with :-
    .AddFilter([MS Office (doc,ppt,rtf,txt,wri,xls)],[*.doc;*.ppt;*.rtf;*.txt;*.wri;*.xls;*.csv])
    .nFileCount = 0 && Reset file count value in case dialog in DO WHILE... loop
    .ShowDialog() && Show dialog

    IF .nFileCount > 0 && File(s) selected
        FOR i = 1 TO ALEN(.aFileNames,1) && Loop through array created
            INSERT INTO FILENAMES (filename) VALUES ( ;
                ADDBS(.cFilepath) ;
                + LOWER(.aFileNames[1,i])) && Insert path\filename.ext in cursor
        ENDF
        BROW LAST
    ELSE
        MESSAGEBOX([You have not made a selection],16,[No files],2000)
    ENDI
ENDW

- gryff15 -
 
Have tried increasing the setting of the MaxFileSize property? By default, it is set to 256. This is the total length in bytes of all the filenames that the user selects. I suspect that, in your case, it is that limit which is being exceeded, rather than the number of files.

That said, I would have serious doubts about using a File Open dialogue to select 1,000 files - if for no other reason that you cannot even see that number of files at one time, so it would mean a lot of horizontal and vertical scrolling while trying to make selections using the CTRL and SHIFT modifiers.

If you really need to let the user select that number of files, perhaps should give them a better mechanism for doing so. Perhaps a grid with checkboxes, and perhaps including some way of selecting filenames using wildcards. Or consider using the Microsoft Listview control (which is included with VFP), and letting them drag the files from there into your application.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I need to select more files because I use the filenames to get the excel files and regenerated the excel files with additional columns and data, instead of editing each excel files. I expect for the cursor to have more than 35 filenames but it doesn't.
- select many files
- append to cursor, add some data and columns
- copy to file with the same name and save to another folder

So I really need to be able to select more files as possible.

- gryff15 -
 
I'm not suggesting that you shouldn't be opening 1,000 files. What I'm saying is that the File Open dialogue is not a good way of letting the user select those files. But you know your application - and your users - better than I do.

Have you tried increasing the MaxFileSize property as per my original suggestion?

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I'm afraid I can't find the MaxFileSize property.
In _comdlg dialoghandler though, there is:
lStructSize = IIF(VAL(OS(3)) > 4, 22, 19) * 4

also,
nArraySize = 1

Not really sure where to find MaxFileSize, no result on find.

- gryff15 -
 
We're obviously looking at different things. I was assuming you are using the Microsoft Common Dialog control that comes with VFP. That control definitely has a MaxFileSize property. (I am looking at it now in the form designer.)

So what is _COMDLG1 in your code?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
It is a class from C:\Program Files (x86)\Microsoft Visual FoxPro 7\Ffc\_system.vcx
The code ran through it when I set stepped on.

_comdlg1 is also the default name of the object when I created a common dialog from component gallery.

- gryff15 -
 
Are you looking for it as a property of the class? If so, it isn't. It is an internal working variable, so to see it (and alter it) you'd need to edit the VCX. Of course I may well be looking at a different version of the _system.vcx (I think I'm looking at the VFP 9.0 version)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top