views:

576

answers:

1

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

OpenFileDialog OFD = new OpenFileDialog();
            OFD.Multiselect = true;
            OFD.Filter = "HTML Files (*.htm*)|*.HTM*|" +
          "All files (*.*)|*.*";

            if (OFD.ShowDialog() == DialogResult.OK)
            {
                progressBar1.Maximum = OFD.FileNames.Count();
                foreach (string s in OFD.FileNames)
                {
                    Console.WriteLine(s);
                    AddAnalytics(s);
                    progressBar1.Value++;
                }
                MessageBox.Show(string.Format("Done! \r\n {0} files completed",progressBar1.Value));
                progressBar1.Value = 0;
            }
+2  A: 

The OpenFileDialog will only use the first 256 characters in the 'file name' field. The field itself displays more, but it ignores anything after the 256 characters.

I believe in your case the missing files are listed after the 256 character mark.

Jay Riggs
I thought of thatthere are 1400ish html filesI did a control+A and then unchecked a few folders ( i doubt a folder would affect it) and then run the code and vola 766 files
Crash893
See my edit. I believe I have your answer.
Jay Riggs
Do you know of a workaround?
Crash893
I also find it odd that it chose the first 776 files in alphabetical order leaving everything past F alone each time.
Crash893
One workaround would be use the FolderBrowserDialog to select a folder. Once selected, you can iterate through all the files in the selected folder and process only those that match your filter. Do you think that would work?
Jay Riggs