Private Sub ButtonGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGenerate.Click
Dim counter As Integer = 0
If TextBox4.Text = TextBox3.Text And TextBox4.Text = TextBox2.Text And TextBox4.Text = TextBox1.Text Then
Dim OldName, NewName, Folder As String
Dim logCount As Integer = 0
Dim TrueFalse As Boolean
StartDir = TextBoxDir.Text
'Variables for writing text log
Dim LogArray() As String
Dim FileWriter As StreamWriter
Dim LogFile As String = StartDir & "LogFile.txt"
'Loop to change names and make log
For counter = 0 To ArrayLengthGlobal - 1 Step 1
'Need Logic To skip files that can not be found. Need to make a log when Skips.
'Have box 1 show log of files skiped
'Have box 2 Show completed message
OldName = StartDir & "\" & Lines2(counter) & "\" & Lines3(counter) & "\" & Lines1(counter)
NewName = Lines4(counter)
Folder = StartDir & "\" & Lines2(counter) & "\" & Lines3(counter)
TrueFalse = My.Computer.FileSystem.FileExists(OldName)
If TrueFalse Then
My.Computer.FileSystem.RenameFile(OldName, NewName)
Else
LogArray(logCount) = OldName
logCount = logCount + 1
End If
Next
FileWriter = New StreamWriter(LogFile, False)
For counter1 = 0 To logCount Step 1
FileWriter.Write(LogArray(counter1))
Next
FileWriter.Close()
'Dim LogString() As String = LogArray
'TextBoxOldNameDir.Text = LogString()
TextBoxNewNameDir.Text = "Complete!"
Else
TextBoxNewNameDir.Text = "Error! Please make sure all files are of same length."
End If
End Sub