renaming files in a folder by other file names in another folder with vb.net

376 views Asked by At

i'm writing a programme and i guess the title explain it all .

and it did work but with one file only , problem is the program ignores the next claarving the first file - the success - is still his priority and he can't find it so it crashes

this is my code

          Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    IO.Directory.SetCurrentDirectory(TextBox2.Text)


    Dim info As New IO.DirectoryInfo(TextBox1.Text)
    Dim imfo2 As New IO.DirectoryInfo(TextBox2.Text)
    For Each fi In imfo2.GetFiles


        For Each foo In info.GetFiles
            Dim namewithoutavi As String = foo.Name.Substring(0, foo.Name.Length - 4)
            Dim fixedname As String = namewithoutavi & ".srt"

            My.Computer.FileSystem.RenameFile(fi.FullName, fixedname)      


        Next

    Next



End Sub     

can someone please tell me how to make it right ? as you can see i'm a beginner and i'm really desperate for help :)

0

There are 0 answers