Link to home
Start Free TrialLog in
Avatar of Kit_Kat111
Kit_Kat111

asked on

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
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
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
Avatar of Kit_Kat111
Kit_Kat111

ASKER

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. :(
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.
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
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
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.
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What would the full path for a valid file name look like?

Bob
That is it! That fixed it!!! YEAH thanks so much guys! I am so thrilled....

Thanks for helping me....!