Results 1 to 4 of 4

Thread: Does OpenFileDialog.FileNames have a limit?

  1. #1

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Does OpenFileDialog.FileNames have a limit?

    I have a small helper app that I use to "inject" scripts into html pages.

    I have an openfiledialog promt and i select all the html files in that directory (1403 files) and no matter what i do i see that OFD.filenames.count = 776

    is there a limit?

    thanks

    C# Code:
    1. OpenFileDialog OFD = new OpenFileDialog();
    2.             OFD.Multiselect = true;
    3.             OFD.Filter = "HTML Files (*.htm*)|*.HTM*|" +
    4.           "All files (*.*)|*.*";
    5.  
    6.             if (OFD.ShowDialog() == DialogResult.OK)
    7.             {
    8.                 progressBar1.Maximum = OFD.FileNames.Count();
    9.                 foreach (string s in OFD.FileNames)
    10.                 {
    11.                     Console.WriteLine(s);
    12.                     AddAnalytics(s);
    13.                     progressBar1.Value++;
    14.                 }
    15.                 MessageBox.Show(string.Format("Done! \r\n {0} files completed",progressBar1.Value));
    16.                 progressBar1.Value = 0;
    17.             }

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Does OpenFileDialog.FileNames have a limit?

    I doubt it has a limit, although I am experiencing the same issue as you (different count). You may have to use a FolderBrowserDialog instead and then use IO.Directory.GetFiles, which works properly.

  3. #3

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: Does OpenFileDialog.FileNames have a limit?

    that's what I've done in this case because all i want is *.htm* files but I kinda of wanted to figure this one out.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,669

    Re: Does OpenFileDialog.FileNames have a limit?

    I would suggest taking a look at the implementation in .NET Reflector to see if you can see a reason that this apparent limit exists.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width