Error: String Cannot Be Of Zero Length

I have a program that should copy files based on listbox selection. Due to the entire path being in listbox I was trying to strip the path out for another variable. My code is below.

What is causing the error:

String Cannot be of zero length. Parameter Name: OldValue
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Me.ProgressBar1.Maximum = 6
        Me.ProgressBar1.Minimum = 0
        Me.ProgressBar1.Value = 0

        Dim sourceRoot As String = SearchLocation.Text
        Dim destinationRoot As String = Review.Text

        Dim FilePath As String
        Dim newfile As String

        newfile = ListBox9.SelectedItem.ToString().Replace(SearchLocation.Text, Review.Text)

        If System.IO.File.Exists(ListBox9.SelectedItem) Then System.IO.File.Copy(ListBox9.SelectedItem, newfile)

        ProgressBar1.Value = +6

    End Sub

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MaxDes101Author Commented:
For reference the review and search location text is populated by a checkmark being checked... with a path as in c:\ or J:\
Error says that you have no text in SearchLocation.Text.
So, you cannot replace nothing with something:
ListBox9.SelectedItem.ToString().Replace(SearchLocation.Text, Review.Text)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.