I want to select multiple files from Common Dialog ...
How to do it ...?
Printable View
I want to select multiple files from Common Dialog ...
How to do it ...?
Set the .Flags property to cdlOFNAllowMultiselect and thats it.
Its also good to Or these other flags to it too.
cdlOFNFileMustExist
cdlOFNPathMustExist
hi Rob..
now i also want to retrieve filenames separately as well..
As Rob said, the cdlOFNAllowMultiselect flag will allow you to select multiple files, I just wanted to elaborate a little. The MSDN states that the files are separated with spaces, which is not correct if you use the Explorer style (and you probably want to do that :)), they are instead separated with null characters. You can separate them using the Split functionIf the user has selected more then one file sFiles(0) will now contain the path to these files and sFiles(1) to sFiles(numberOfFilesSelected) will contain their file names.VB Code:
Dim sFiles() As String '... other code to show the Open dialog sFiles = Split(CommonDialog1.FileName, vbNullChar)
You might also want to change the MaxFileSize property. Despite the name of this property it has nothing todo with the files size on disk but rather the maximum length of the string the FileName property will return. The default value is 256, which is usually fine for selecting only one file, but since you want the user to be able to select more then that you should increase it's value. The max value for this property is 4,294,967,295 which should be more then enough :)