Jump to content

Foreach Dongu & Dosyaları Okuma


korasoglu
 Share

Recommended Posts

Merhaba,

 

denedim c# yüklü değil, sen bi dene

FolderBrowserDialog fbd = new FolderBrowserDialog();
                dataGridView1.ColumnCount = 1;
                dataGridView1.Columns[0].Name = "Dosyalar";

                string[] files = Directory.GetFiles(fbd.SelectedPath);
                for (int i = 0; i >= files.Length ; i++)
                {
                    string[] row1 = new string[] { files.ToString() };
                    dataGridView1.Rows.Add(row1);
                }
Link to comment
Share on other sites

Bunlar çalışmadı aynı zamanda foreach kullanılsan daha isabetli olmazmı

 

Şu yeterli fakat dosya isimlerini alamadım donen f onunda FileInfo alınacak ama beceremedim yardım ederseniz sevinirim.

 

FolderBrowserDialog dialog = new FolderBrowserDialog();
            dialog.Description = "Seçim Yapınız";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                listBox1.Items.Clear();
                listBox1.Refresh();
                //dataGridView1.ColumnCount = 2;
               // dataGridView1.Columns[0].Name = "isa";
                //dataGridView1.Columns[1].Name = "avci";
                string folderName = dialog.SelectedPath;
                foreach (string f in Directory.GetFiles(folderName))//(folderName)
                {
                    // şu şekilde sorun çözülüyor
                    FileInfo dosyabilgisi = new FileInfo(f);
                    listBox1.Items.Add(dosyabilgisi);
                    listBox1.Items.Add(f);
                    string[] row1 = new string[] { folderName.ToString(), folderName.ToString() };
                  dataGridView1.Rows.Add(row1);
                   
                }
            }
Edited by korasoglu
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...