Hey guys, I have a method that gets all the file names in a folder that have a certain extension..such as ".env" or whatever. It puts those names in an array which is returned thru the method. I then loop thru this array of file names.

The problem is, if there are only one or two files in the folder it returns nothing. If there are three files it returns one, if there are 4 files it returns two etc..

It seems to not be giving me a correct count.

Here is the code, any help is appreciated!

PHP Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace 
WindowsApplication2
{
    public 
partial class Form1 Form
    
{
        public 
Form1()
        {
            
InitializeComponent();
        }

        private 
void button1_Click(object senderEventArgs e)
        {
                    
string[] theFiles;
                    
theFiles = new string[] { };
                    
string lastScan "3/21/2003 11:12:23 AM";
                    
string path "C:\\test";
                    
DateTime scan Convert.ToDateTime(lastScan);
                    
theFiles GetFilesAfterDate(pathscan);

                    for (
int i 0theFiles.Length 1i++)
                    {
                        
MessageBox.Show(theFiles[i]);
                    }
//end for

        
}//end button1_Click

        
public string[] GetFilesAfterDate(string folderDateTime date)
        {
            
FileInfo[] files = new DirectoryInfo(folder).GetFiles("*.env");
            List<
FileInfofileList = new List<FileInfo>();

            if (
files.Length 0)
            {
                for (
int index 0index files.GetUpperBound(0); index++)
                {
                    if (
files[index].LastWriteTime >= date)
                    {
                        
fileList.Add(files[index]);
                    }
//end if
                
}//end for
            
}//end if

            
string[] filePaths = new string[fileList.Count];

            for (
int index 0index filePaths.GetUpperBound(0); index++)
            {
                
filePaths[index] = fileList[index].Name;
            }
//end for

            
return filePaths;
        }
//end GetFilesAfterDate
    
}