byhabit Posted June 28, 2015 Share Posted June 28, 2015 Selam agda paylasilan bi klasor var ve icinde simdilik yaklasik 3000 klasor daha var. Her klasorun adi, kisi adi ve soyadi ile olusuyor ve her dosyanin icinde resim dosyasi var. Agdan windows explorer ile baglanip sag ustten aramaya isim yazip ilgili klasoru bulup aciyorum, ve bu islem bazen uzun surebiliyor, hep bu islemi hizlandircak bir calisma varmidir, aradim bulamadim yada yapabilirmiyiz (veri tabani olarak agdaki bi klasoru bagliycam, programda arama bolumune isim yazarken filtreleyerek klasorleri listeliyecek.) Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted June 28, 2015 Editor Share Posted June 28, 2015 Bir ağ sürücüsü gibi eklerseniz. Windows bunu dizin oluşturma hizmeti sayesinde indexleyecektir. Bundan sonraki aramalarınız ister SearchEverything ile hızlıca yaparsınız isterseniz C# ile yapacaksanızda buradaki Windows Search ün api sini kullanabilirsiniz. http://stackoverflow.com/questions/19272920/enumerating-files-of-specific-type-in-windows Quote Link to comment Share on other sites More sharing options...
KintaRo Posted June 29, 2015 Share Posted June 29, 2015 3000 küsür kişilik bir klasör listesi oluşturdum. Daha sonra C# string[] ve foreach kullanarak arama yaptırdım, sonuç gayet başarılı. Önemli olan formun ilk açılışında klasör listesini bir kere hafızaya almak ve bundan sonraki aramalarda hafızadaki dizi den arama yapmak. Yani her seferinde listeyi hafızaya almaya ya da direk klasörler içinde arama yapmaya gerek yok. Tabi bu klasör listesi çok sık aralıklarla yenileniyorsa timer ve backgroundworker ile ara ara listeyi yenilemek gerekir. Listview'deki sonuclara çift tiklarsanız klasörü açar. isimlerin içinde olduğu klasör proje içindedir. https://yadi.sk/d/cpRDVvYxhYjgo Quote Link to comment Share on other sites More sharing options...
byhabit Posted June 29, 2015 Author Share Posted June 29, 2015 eyvallah üstad ellerine sağlık Quote Link to comment Share on other sites More sharing options...
KintaRo Posted June 29, 2015 Share Posted June 29, 2015 performans nasıl? ben i7 işlemci ve ssd hard disk ile denedim, çok iyi çalıştı. Yavaş makinalarda performansı merak ediyorum. Quote Link to comment Share on other sites More sharing options...
byhabit Posted June 30, 2015 Author Share Posted June 30, 2015 performans iyi sıkıntı yok ama arama yaparken isim yazıp enter'a basmadan isimler çıkmıyor. Yani ismi yazarken filtreleme yapsa daha iyi olurdu onuda bulabilirsem tadından yenmez :) =1.nesil i5 işlemci 5400rpm hdd 4gb ram ile test ediyorum program hiç kasılmıyor bu kadar çok kayıta rağmen Quote Link to comment Share on other sites More sharing options...
KintaRo Posted July 1, 2015 Share Posted July 1, 2015 Onun çözümü basit. TextBox KeyDown evresinde if (e.KeyCode == Keys.Enter) { listView1.Items.Clear(); foreach (string item in klasorler) { string metin = textBox1.Text; if (item.IndexOf(metin, 0, StringComparison.CurrentCultureIgnoreCase) != -1) { listView1.Items.Add(new DirectoryInfo(item).Name); } } } kodları şunlarla değiştirin: listView1.Items.Clear(); foreach (string item in klasorler) { string metin = textBox1.Text; if (item.IndexOf(metin, 0, StringComparison.CurrentCultureIgnoreCase) != -1) { listView1.Items.Add(new DirectoryInfo(item).Name); } } Quote Link to comment Share on other sites More sharing options...
byhabit Posted July 3, 2015 Author Share Posted July 3, 2015 Onun çözümü basit. TextBox KeyDown evresinde if (e.KeyCode == Keys.Enter) { listView1.Items.Clear(); foreach (string item in klasorler) { string metin = textBox1.Text; if (item.IndexOf(metin, 0, StringComparison.CurrentCultureIgnoreCase) != -1) { listView1.Items.Add(new DirectoryInfo(item).Name); } } } kodları şunlarla değiştirin: listView1.Items.Clear(); foreach (string item in klasorler) { string metin = textBox1.Text; if (item.IndexOf(metin, 0, StringComparison.CurrentCultureIgnoreCase) != -1) { listView1.Items.Add(new DirectoryInfo(item).Name); } } Bunu denedim bir değişiklik olmadı, ama bende biyerde hata yapıyor olabilirim, bu programın çok acemisiyim. Oruç ve iş bir arada pek fırsat bulamadım denemek için en kısa zamanda tekrar deniycem kurcalarım biraz daha kodlar doğru olabilir ama isim yazıp enter a basmadan listelemiyor. Saygılar Quote Link to comment Share on other sites More sharing options...
KintaRo Posted July 4, 2015 Share Posted July 4, 2015 Ben denemedim, ama çalışması lazım. Olmadı TextChanged eventinde deneyin. Quote Link to comment Share on other sites More sharing options...
byhabit Posted July 4, 2015 Author Share Posted July 4, 2015 tamam çalıştı sorun yok hızı da gayet iyi hızlı olamsının sebebi isim listesini txt ye kaydedip ordan okuması bu şekilde çok hızlı çalışıyor. ama direk klasörleri gösterdiğim zaman kasılıyor yine. böyle iyi oldu yardımlarınız için teşekkürler. Quote Link to comment Share on other sites More sharing options...
byhabit Posted July 14, 2015 Author Share Posted July 14, 2015 programı bu şekilde yaptım vede kullanıyorum bütün pc lerde çok hızlı ve sorunsuz sadece iki tane all in one shutle pc lerde çok kasılıyor. bu kasılmayı bir nebze azaltmak için şöyle yapabilirmiyiz, arama yaparken karışık arıyor ilk sıradan aratabilirmiyiz örneğin a harfine bastığımda içinde a olan isimleri değilde a ile başlıyan isimleri listeletebilirmiyiz mümkünmüdür? Quote Link to comment Share on other sites More sharing options...
KintaRo Posted July 14, 2015 Share Posted July 14, 2015 şu şekilde yapınca olması lazim: (yapılandırma farklı olduğu için deneyemedim) private void textBox1_KeyDown(object sender, KeyEventArgs e) { listView1.Items.Clear(); StreamReader oku; oku = File.OpenText(Application.StartupPath + "\\isimler2.txt"); string yazi; while ((yazi = oku.ReadLine()) != null) { string metin = textBox1.Text; if (yazi.Substring(0, metin.Length) == metin) { listView1.Items.Add(new DirectoryInfo(yazi).Name); } } oku.Close(); } yani burada dedik ki, sıradaki satırın ilk karakterinden arama metni uzunluğundaki metni al, aranan metin ile karşılaştır. sıradaki satır Ahmet San diyelim, siz Ah yazdığınızda satırı listeye eklemesi lazim. ama yine de tüm listeyi tarayacaktır. Quote Link to comment Share on other sites More sharing options...
byhabit Posted August 22, 2015 Author Share Posted August 22, 2015 tekrar konuyu hortlatıyorum ama Projede Biraz değişiklik yaptım ve bazı bilgisayarlarda ağır çalışma sorununu hallettim artık yavaşlık söz konusu değil. sadece yenile butonuna bastığımda projede belirttiğim ağ yolundaki klasör listesini txt ye çekemedim yardımcı olabilirmisiniz :) proje Down kodlar : [spoiler]using System; using System.Diagnostics; using System.IO; using System.Linq; using System.Windows.Forms; using System.Collections; using System.Text; using System.Drawing; namespace Arama { public partial class Klinik : Form { string[] klasorler, dosyayolu; int gosterilecekKayitSayisi = 20; string agYolu = @"\\RONTGEN\RONTGEN\"; public Klinik() { InitializeComponent(); } ArrayList isimListesi; private void Form1_Load(object sender, EventArgs e) { verileriGetir(); } private void verileriGetir() { isimListesi = new ArrayList(); using (StreamReader reader = new StreamReader(Application.StartupPath + "\\isimler.txt", Encoding.GetEncoding("iso-8859-9"))) { string line; while ((line = reader.ReadLine()) != null) { isimListesi.Add(line); } } } private void button1_Click(object sender, EventArgs e) { verileriGetir(); listView1.Items.Clear(); lbl_bildirim.Visible = true; tmr_goster.Start(); } private void listView1_DoubleClick(object sender, EventArgs e) { if (listView1.SelectedItems[0].Selected) { MessageBox.Show(agYolu + listView1.SelectedItems[0].Text); Process.Start(agYolu + listView1.SelectedItems[0].Text); } } private void tmr_goster_Tick(object sender, EventArgs e) { lbl_bildirim.Visible = false; tmr_goster.Stop(); } private void textBox1_TextChanged(object sender, EventArgs e) { listView1.Items.Clear(); TextBox txt = (TextBox)sender; int say = 0; for (int i = 0; i < isimListesi.Count; i++) { string _kayit = isimListesi[i].ToString().ToUpper().Replace(agYolu + @"\", ""); if (_kayit.IndexOf(txt.Text.ToUpper()) != -1) { listView1.Items.Add(_kayit); say++; } if (say == gosterilecekKayitSayisi) { break; } } } } } [/spoiler] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.