FileNotFoundException was unhandled - HELP! file does exist.

Don't know why I am getting this error:

FileNotFoundException was unhandled

    Private Sub cmbTime_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbTime.SelectedIndexChanged

        Dim folder As String = "C:\Projects\Darryl\Queue Review Files\" & DateTime.ParseExact(cmbDate.SelectedItem.ToString, "MMMM d, yyyy", Nothing).ToString("M-d") & "\Cam {0}\" & cmbTime.Text

        For i As Integer = 1 To 8

            Dim pcb As PictureBox = ApplicationControls.FindControl(Me, "pcbCam" & i)

            If Not pcb Is Nothing Then
                pcb.Image = Image.FromFile(String.Format(folder, i)) <<<<<<<<<<
            End If

        Next i

    End Sub
Kit_Kat111Asked:
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.

Carl TawnSystems and Integration DeveloperCommented:
What is it that you want to do ? i.e. what is it that you expect "String.Format(folder, i))" to produce ?

The file not found exception suggests that the path to your image is not being formed correctly.
0
Bob LearnedCommented:
Yes, you need to look at the value of 'folder'.

My guess is that you have an extra space here:  Cam {0}.  Should it be Cam{0}?

Bob
0
Kit_Kat111Author Commented:
Thanks Carl and Bob!

C:\Projects\Darryl\Queue Review Files\2-24\Cam 2\Cam1-20060224165653-01.jpg

Nope the test one I put in each folder came up, which was named cam1, but another file that is in each folder doesn't come up. See the jpg name of the file path that had an error, it says Cam1 when it is in the Cam2 folder. :(
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Carl TawnSystems and Integration DeveloperCommented:
The file name in your sample comes from cmbTime.Text, so that must be where the incorrect Cam1 in the file name is coming from.
0
DotNetLover_BaanCommented:
Hi Buddy,
ok.. lets see.... looks like you are not getting the right value from cmbTime selection. Try cmbTime.SelectedItem.ToString

        Dim folder As String = "C:\Projects\Darryl\Queue Review Files\" & DateTime.ParseExact(cmbDate.SelectedItem.ToString, "MMMM d, yyyy", Nothing).ToString("M-d") & "\Cam {0}\" & cmbTime.SelectedItem.ToString

-Baan
0
Kit_Kat111Author Commented:
It is so nice to see you!!

I am still getting that error: FileNotFoundException

C:\Projects\Darryl\Queue Review Files\2-24\Cam 2\Cam1-20060224170000-01.jpg

What i need is
C:\Projects\Darryl\Queue Review Files\2-24\Cam 2\Cam2-20060224170000-01.jpg

Do you have rain today? It is cold here...brrr
0
Kit_Kat111Author Commented:
AH!! I think I know what it is...

Perhaps the combo box is keeping that file.

Okay.

1. User selects from combobox Date "February 24, 2006" which equals the 2-24
folder.
2. This populates another combo box with files from the default folder,
Cam1, so there will be tons of
Cam1-20060224165648-01.jpg
Cam1-20060224165649-01.jpg
Cam1-20060224165650-01.jpg
Cam1-20060224165651-01.jpg
and so on.

So...I need to take that off,  a split or something?
take that off and add what the appropiate folder is like Cam6.

I see that must be the problem....can you help me fix this?

thanks everyone for all the help.

Thank you for putting up with me.
0
Carl TawnSystems and Integration DeveloperCommented:
Try changing:

Dim folder As String = "C:\Projects\Darryl\Queue Review Files\" & DateTime.ParseExact(cmbDate.SelectedItem.ToString, "MMMM d, yyyy", Nothing).ToString("M-d") & "\Cam {0}\" & cmbTime.Text

To:

Dim folder As String = "C:\Projects\Darryl\Queue Review Files\" & DateTime.ParseExact(cmbDate.SelectedItem.ToString, "MMMM d, yyyy", Nothing).ToString("M-d") & "\Cam {0}\Cam{0}" & cmbTime.Text.SubString(cmbTime.Text.IndexOf("-"))
0

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
Bob LearnedCommented:
What would the full path for a valid file name look like?

Bob
0
Kit_Kat111Author Commented:
That is it! That fixed it!!! YEAH thanks so much guys! I am so thrilled....

Thanks for helping me....!
0
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
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.