31 Mayıs 2014 Cumartesi
RECURSİVE - Kendi içinde kendini çağırabilen fonksiyon
RECURSİVE PROJE KODLARINI
İNDİR
Imports System.IO Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load BaslamaDiziniTxt.Text = My.Settings.StartDirectory CmbUzanti.Text = My.Settings.Pattern End Sub Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing My.Settings.StartDirectory = BaslamaDiziniTxt.Text My.Settings.Pattern = CmbUzanti.Text My.Settings.Save() End Sub Private Sub BtnBul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBul.Click DosyaAra(DsyListesi, BaslamaDiziniTxt.Text, CmbUzanti.Text, BulTxt.Text, Nothing) End Sub Private Sub btnDizinSec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDizinSec.Click DznSecDialog.SelectedPath = BaslamaDiziniTxt.Text If (DznSecDialog.ShowDialog() = DialogResult.OK) Then BaslamaDiziniTxt.Text = DznSecDialog.SelectedPath End If End Sub Private Sub DosyaAra(ByVal LstBasi As ListBox, ByVal İlkDzn As String, _ ByVal Ornek As String, ByVal Diziden As String, ByVal Diziye As String) Try DsyListesi.Items.Clear() Dim Uzanti() As String = Uzanti_ayristir(Ornek) If (Diziden.Length < 1) Then Diziden = Nothing Dim Dzn_Bilgisi As New DirectoryInfo(İlkDzn) DizinAra(LstBasi, Dzn_Bilgisi, Uzanti, Diziden, Diziye) If (Diziden Is Nothing) Then Label3.Text = "Bulunan Dosya sayısı " & LstBasi.Items.Count & " Adet." Else MessageBox.Show("Yapılan değiştirmeler içinde " & LstBasi.Items.Count & " dosya.") End If Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub DizinAra(ByVal LstBasi As ListBox, ByVal Dzn_Bilgisi As DirectoryInfo, _ ByVal Uzanti() As String, ByVal Diziden As String, ByVal Diziye As String) For Each Ornek As String In Uzanti For Each Dsy_Bilgisi As FileInfo In Dzn_Bilgisi.GetFiles(Ornek) Dsy_islemi(LstBasi, Dsy_Bilgisi, Diziden, Diziye) Next Dsy_Bilgisi Next Ornek For Each subdir_info As DirectoryInfo In Dzn_Bilgisi.GetDirectories() DizinAra(LstBasi, subdir_info, Uzanti, Diziden, Diziye) Next subdir_info End Sub Private Sub Dsy_islemi(ByVal LstBasi As ListBox, ByVal Dsy_Bilgisi As FileInfo, ByVal Diziden As String, ByVal Diziye As String) Try If (Diziden Is Nothing) Then LstBasi.Items.Add(Dsy_Bilgisi.FullName) Else Dim txt As String = System.IO.File.ReadAllText(Dsy_Bilgisi.FullName) If (txt.Contains(Diziden)) Then LstBasi.Items.Add(Dsy_Bilgisi.FullName) If (Diziye IsNot Nothing) Then System.IO.File.WriteAllText(Dsy_Bilgisi.FullName, _ txt.Replace(Diziden, Diziye)) End If End If End If Catch ex As Exception MessageBox.Show("Hata işleme dosyası" & _ Dsy_Bilgisi.FullName & "\n" & ex.Message) End Try End Sub Private Function Uzanti_ayristir(ByVal Strng_Uzanti As String) As String() If (Strng_Uzanti.Contains("(")) Then Strng_Uzanti = MetinArasinda(Strng_Uzanti, "(", ")") End If Dim Sonuc() As String = Strng_Uzanti.Split(";"c) For i As Integer = 0 To Sonuc.Length - 1 Sonuc(i) = Sonuc(i).Trim() Next i Return Sonuc End Function Private Function MetinArasinda(ByVal txt As String, ByVal Limit1 As String, ByVal Limit2 As String) As String Dim Yer1 As Integer = txt.IndexOf(Limit1) Dim text_Baslangici As Integer = Yer1 + Limit1.Length Dim Yer2 As Integer = txt.IndexOf(Limit2, text_Baslangici) Return txt.Substring(text_Baslangici, Yer2 - text_Baslangici) End Function Private Sub DsyListesi_DoubleClick(ByVal sender As Object, ByVal e As EventArgs) Handles DsyListesi.DoubleClick For Each Secilen_Dsy As String In DsyListesi.SelectedItems System.Diagnostics.Process.Start(Secilen_Dsy) Next Secilen_Dsy End Sub End Class
Hiç yorum yok:
Yorum Gönder
Sonraki Kayıt
Önceki Kayıt
Ana Sayfa
Kaydol:
Kayıt Yorumları (Atom)
Hiç yorum yok:
Yorum Gönder