FileNotFoundException was unhandled - HELP! file does exist.

Posted on 2006-03-23
Medium Priority
Last Modified: 2012-08-14
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
Question by:Kit_Kat111
  • 4
  • 3
  • 2
  • +1
LVL 52

Expert Comment

by:Carl Tawn
ID: 16275565
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.
LVL 96

Expert Comment

by:Bob Learned
ID: 16276036
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}?


Author Comment

ID: 16276535
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. :(

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

LVL 52

Expert Comment

by:Carl Tawn
ID: 16279084
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.
LVL 18

Expert Comment

ID: 16279450
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


Author Comment

ID: 16280299
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

Author Comment

ID: 16280568
AH!! I think I know what it is...

Perhaps the combo box is keeping that file.


1. User selects from combobox Date "February 24, 2006" which equals the 2-24
2. This populates another combo box with files from the default folder,
Cam1, so there will be tons of
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.
LVL 52

Accepted Solution

Carl Tawn earned 2000 total points
ID: 16280692
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


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("-"))
LVL 96

Expert Comment

by:Bob Learned
ID: 16280716
What would the full path for a valid file name look like?


Author Comment

ID: 16281078
That is it! That fixed it!!! YEAH thanks so much guys! I am so thrilled....

Thanks for helping me....!

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question