Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

try catch error...

Status
Not open for further replies.

magmo

Programmer
May 26, 2004
291
SE
Hi


I try this code in VS..


Code:
    Private Sub Submit1_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit1.ServerClick
        If Not File1.PostedFile Is Nothing And File1.PostedFile.ContentLength > 0 Then
            Dim fn As String = System.IO.Path.GetFileName(File1.PostedFile.FileName)
            Dim SaveLocation As String = Server.MapPath("Data") & "\" & fn
            Try
                File1.PostedFile.SaveAs(SaveLocation)
                Response.Write("The file has been uploaded.")
            Catch ex As exception
                Response.Write("Error: " & ex.ToString)
            End Try
        Else
            Response.Write("Please select a file to upload.")
        End If
    End Sub


But I get this error...

'Catch' cannot catch type 'exception' because it is not 'System.Exception' or a class that inherits from 'System.Exception'.


What is wrong with this code?


Regards
 
It may be that you have another class within your project which has a "exception" method. Try using System.Exception instead (as is suggested by VS).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hi



Worked just fine, Thanks!


Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top