|
-
May 23rd, 2013, 03:00 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] getIcon func exceptions
hey
I'm getting many exceptions relating to:
Code:
Public Function getIcon(ByVal path As String) As Icon
Try
Return System.Drawing.Icon.ExtractAssociatedIcon(path)
Catch ex As System.Exception
Return Nothing
End Try
End Function
exceptions:
Code:
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in System.Drawing.dll
Please can someone help solve?
-
May 23rd, 2013, 03:04 PM
#2
Re: getIcon func exceptions
...well...do you see what the Exception tells you? It says FileNotFoundException which means the path you're giving the function is invalid! So why don't you work on showing what the path is when an exception is thrown instead of ignoring and returning nothing! You might as well have put
Code:
On Error Resume Next
in your function as that's essentially what you're doing.
Note that I linked you to MSDN for the exception. You should ALWAYS consult the documentation if you don't understand what's going on. I literally went to Bing (it even works the same on Google and Yahoo! as well) and typed in "System.IO.FileNotFoundException" and the MSDN library was the first result.
Last edited by formlesstree4; May 23rd, 2013 at 03:18 PM.
Reason: I checked Google & Yahoo! too.
-
May 23rd, 2013, 04:36 PM
#3
Thread Starter
Hyperactive Member
Re: getIcon func exceptions
-
May 23rd, 2013, 06:15 PM
#4
Re: getIcon func exceptions
Yes it works if the filepath points to a file that actually exists. What I don't understand is how you're getting errors with the Try/Catch in place to ignore them!
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
May 23rd, 2013, 06:21 PM
#5
Thread Starter
Hyperactive Member
Re: getIcon func exceptions
 Originally Posted by formlesstree4
...well...do you see what the Exception tells you? It says FileNotFoundException which means the path you're giving the function is invalid! So why don't you work on showing what the path is when an exception is thrown instead of ignoring and returning nothing! You might as well have put
Code:
On Error Resume Next
in your function as that's essentially what you're doing.
Note that I linked you to MSDN for the exception. You should ALWAYS consult the documentation if you don't understand what's going on. I literally went to Bing (it even works the same on Google and Yahoo! as well) and typed in "System.IO.FileNotFoundException" and the MSDN library was the first result.
Yo don't u think i'd already researched it, that "on error resume next" is no use, with the try and catch........
-
May 23rd, 2013, 06:27 PM
#6
Thread Starter
Hyperactive Member
Re: getIcon func exceptions
 Originally Posted by dunfiddlin
Yes it works if the filepath points to a file that actually exists. What I don't understand is how you're getting errors with the Try/Catch in place to ignore them!
exceptions bud, no erros...........
-
May 23rd, 2013, 06:31 PM
#7
Re: getIcon func exceptions
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
May 23rd, 2013, 06:32 PM
#8
Re: getIcon func exceptions
 Originally Posted by chris-2k
exceptions bud, no erros...........
Well any exceptions caught by a try-catch are shown in the immediate window, if that is what you mean that is normal.
-
May 23rd, 2013, 07:10 PM
#9
Thread Starter
Hyperactive Member
Re: getIcon func exceptions
 Originally Posted by Edgemeal
Well any exceptions caught by a try-catch are shown in the immediate window, if that is what you mean that is normal.
Yea it is, so the exceptions are only there when something is wrong...
How can i see what value path is holding?
-
May 23rd, 2013, 07:27 PM
#10
Thread Starter
Hyperactive Member
Re: getIcon func exceptions
My brother dcrew fixed it, thanks for trying to help though.
Code:
Public Function getIcon(ByVal path As String) As Icon
If (File.Exists(path)) Then Return System.Drawing.Icon.ExtractAssociatedIcon(path)
Return Nothing
End Function
edit: it was also another piece of code that needed fixing, he fixed though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|