I can see two immediate problems with your code:
- You're looping over the file array twice
- You're not creating a new
ListViewItem
each time you add it to the list
foreach (FileInfo file in Dosyalar)
{
ListViewItem item = new ListViewItem();
for (int i = 1; i < Dosyalar.Length; i++)
{
You don't even need to reference
Dosyalar.Length
, you can instead just use an index variable to track the current item:
int index = 1;
foreach (FileInfo file in Dosyalar)
{
ListViewItem item = new ListViewItem();
item.Text = index.ToString();
item.SubItems.Add(file.Name);
listView2.Items.Add(item);
index++;
}