I am making a program which finds duplicate files in a directory, but when the directory it is searching has too many of those files it will crash the application. I was wondering if there is a way to buffer the amount of files it grabs. Here is the code that does the thing I am explaining:
string[] filePathsb = Directory.GetFiles(
@"" + Dirfind, "*" + filetyperest, SearchOption.AllDirectories);
for (int i = 0; i < filePathsb.Length; i++)
{
ListBoxItem itm = new ListBoxItem();
try
{
List<TodoItem> items = new List<TodoItem>();
filelistboxitem.Items.Add(new TodoItem() { Title = "" + filePathsb[i], Deletea = "" + i });
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("Error occurance: " + ex);
}
}
Just a note: this works fine when there are about < 50 files.