PRB: Common Dialog Open: Err=20476 Buffer lpstrFile Too SmallID: Q110185
|
The following behavior occurs with the Open file dialog box of the Common
Dialog custom control when you set the Flags property to &H200& or
OFN_ALLOWMULTISELECT, to allow selection of more than one file at once.
If you highlight more than about 20 files at once in the Open file dialog
box, the following error message displays when you click the OK button:
The buffer at which the member lpstrFile points is too small.
Invalid filename.
This behavior occurs when the length of the Open dialog string containing the file names exceeds 256, the default MaxFileSize property value.
To resolve the problem, increase the MaxFileSize property to 2048:
CMDialog1.MaxFileSize = 2048
This behavior is by design.
You can set the Flags property of the Common Dialog to &H200&, or
OFN_ALLOWMULTISELECT, to allow multiple selections in the File Name list
box. You can select more than one file at run time by pressing the SHIFT
key and using the UP and DOWN ARROW keys to select the desired files. The
FileName property returns a string containing the names of all selected
files. The names in the string are delimited by spaces.
Sub Form_Load ()
CMDialog1.Flags = &H200& ' Allows selection of more than 1 file.
CMDialog1.Filter = "ALL|*.*" ' File types to list in file box.
' CMDialog1.MaxFileSize = 2048 ' Add this to correct the behavior.
CMDialog1.Action = 1 ' Action 1 = standard Open file dialog box
End Sub
If error trapping (On Error Goto) is on, the Err function reports error number 20476. In the Visual Basic environment, if you press F5 or choose Continue from the Run menu after getting this error, you get the following error message:The buffer at which the member lpstrFile points is too small.
Invalid filename.
The following corrections apply to the "Language Reference":
Additional query words: 3.00
Keywords : kbcode PrgCtrlsCus
Version : 3.00
Platform : WINDOWS
Issue type :
Last Reviewed: June 22, 1999