too many files for openFileDialog (c#)

Juno

New member
Joined
Aug 1, 2003
Messages
3
Location
Cologne Germany (DE)
Hi folks! Great Forum, good point that it is manged in sections for each kind of issue.

My problem:
I use openFileDialog in C# with multiselect=true;
if the user takes about 600 files of a directory, the runtime will give him the following message: "Too many files selected" ot that like (I translate this from German language)

What can I do to avoid this?

Thnak you for everyone that will answer me
 
Ive never heard of having that problem before. The best bet
would be to pop a message box to the user informing them that
they selected too many files, and also telling them to select less
next time. Then re-open the dialog box so they can try again.
 
But this I dont want to do,

because Ive written a tool for work with big collections of files.

(recognize files with differnt names, renaming them, and so on)
 
why not specify a limit if its causing a problem? heres a little example i made for you , not sure if it helps but it may :
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim od As New OpenFileDialog()
        With od
            .Multiselect = True
            .Filter = "Text(*.txt)|*.txt"
            .InitialDirectory = "C:\"
            If .ShowDialog = DialogResult.OK Then
                If .FileNames.Length > 10 Then /// max limit goes here.
                    MessageBox.Show("To many files chosen!")
                Else
                    .OpenFile()
                End If
            End If
        End With

    End Sub
 
You could require that the files all be placed in the same
directory, and use the Browse for Folder dialog class from EliteVB
to select that foder.
 
but I must work with 500 files!

thank you for answering me. But I really do want to work with hundreds of files in one directory.

Im writing a tool to rename serials of files in directorys. So it is important for me, that I can handle big quantities of files. For Example, the user wants to rename all files in a drirectory but one; so, he will first select all files (Ctrl+A) and then he will de-select thos ones that he doenst want to process. Thats an ordinary scene, I think.

So, I dont want to send error-messages, I really want to work with hundreds of files in one selection.
 
Well youre clearly not going to able to reach your goal with the
OpenFileDialog control (Hey, that rhymes!). If you have VB6, you
could create an ActiveX control that uses the FileListBox, DriveListBox,
and DirListBox to select your files. Or you could just create your
own form in C# that populates listboxes with directories and files
using classes found in the System.IO napespace.

Other than that, I dont know what to say. If you can find or
create an alternate open file dialog that doesnt rely on the
Windows Common Dialog control, then all the more power to you.
 
Back
Top