[code] Function FindListBox2ItemThatContains(ByVal listBox1FileName As String) As String
For i As Integer = 0 To ListBox2.Items.Count - 1
If ListBox2.Items(i).Name.Trim.toupper.Contains(listBox1FileName.Trim.ToUpper) Then
Return ListBox2.Items(i).Name.trim
End If
Next
Return ""
End Function[/code]
next, i have a third button that runs the code, and copies/pastes the new files into location using the file from list 1 and renames it with the file from list 2. the saved location used to be specified by the user, but now i need the code to just overwrite the file from list 1 in it's current location. Here's the existing loop function...(note: the new path hasn't been finalized yet because i don't know how to code for it.[code]For Each file As IO.FileInfo In ListBox1.CheckedItems
Dim NewFileName As String = FindListBox2ItemThatContains(file.Name)
If NewFileName.Trim.Length > 0 Then IO.File.Copy(file.FullName, IO.Path.Combine(FBD2.SelectedPath, "item parent folder", NewFileName.Trim), True)
ProgressBar1.Increment(+1)
Next[/code]
how do i retrieve the file location from list 2, and save the new file in that location?[code] Function FindListBox2ItemThatContains(ByVal listBox1FileName As String) As String
For i As Integer = 0 To ListBox2.Items.Count - 1
If ListBox2.Items(i).Name.Trim.toupper.Contains(listBox1FileName.Trim.ToUpper) Then
Return ListBox2.Items(i).Name.trim
End If
Next
Return ""
End Function[/code]
next, i have a third button that runs the code, and copies/pastes the new files into location using the file from list 1 and renames it with the file from list 2. the saved location used to be specified by the user, but now i need the code to just overwrite the file from list 1 in it's current location. Here's the existing loop function...(note: the new path hasn't been finalized yet because i don't know how to code for it.[code]For Each file As IO.FileInfo In ListBox1.CheckedItems
Dim NewFileName As String = FindListBox2ItemThatContains(file.Name)
If NewFileName.Trim.Length > 0 Then IO.File.Copy(file.FullName, IO.Path.Combine(FBD2.SelectedPath, "item parent folder", NewFileName.Trim), True)
ProgressBar1.Increment(+1)
Next[/code]
how do i retrieve the file location from list 2, and save the new file in that location?[code] Function FindListBox2ItemThatContains(ByVal listBox1FileName As String) As String
For i As Integer = 0 To ListBox2.Items.Count - 1
If ListBox2.Items(i).Name.Trim.toupper.Contains(listBox1FileName.Trim.ToUpper) Then
Return ListBox2.Items(i).Name.trim
End If
Next
Return ""
End Function[/code]
next, i have a third button that runs the code, and copies/pastes the new files into location using the file from list 1 and renames it with the file from list 2. the saved location used to be specified by the user, but now i need the code to just overwrite the file from list 1 in it's current location. Here's the existing loop function...(note: the new path hasn't been finalized yet because i don't know how to code for it.[code]For Each file As IO.FileInfo In ListBox1.CheckedItems
Dim NewFileName As String = FindListBox2ItemThatContains(file.Name)
If NewFileName.Trim.Length > 0 Then IO.File.Copy(file.FullName, IO.Path.Combine(FBD2.SelectedPath, "item parent folder", NewFileName.Trim), True)
ProgressBar1.Increment(+1)
Next[/code]
how do i retrieve the file location from list 2, and save the new file in that location?[code] Function FindListBox2ItemThatContains(ByVal listBox1FileName As String) As String
For i As Integer = 0 To ListBox2.Items.Count - 1
If ListBox2.Items(i).Name.Trim.toupper.Contains(listBox1FileName.Trim.ToUpper) Then
Return ListBox2.Items(i).Name.trim
End If
Next
Return ""
End Function[/code]
next, i have a third button that runs the code, and copies/pastes the new files into location using the file from list 1 and renames it with the file from list 2. the saved location used to be specified by the user, but now i need the code to just overwrite the file from list 1 in it's current location. Here's the existing loop function...(note: the new path hasn't been finalized yet because i don't know how to code for it.[code]For Each file As IO.FileInfo In ListBox1.CheckedItems
Dim NewFileName As String = FindListBox2ItemThatContains(file.Name)
If NewFileName.Trim.Length > 0 Then IO.File.Copy(file.FullName, IO.Path.Combine(FBD2.SelectedPath, "item parent folder", NewFileName.Trim), True)
ProgressBar1.Increment(+1)
Next[/code]
how do i retrieve the file location from list 2, and save the new file in that location?
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w