Thread: File upload
View Single Post
  #3 (permalink)  
Old January 8th, 2009, 10:55 AM
alliancejhall alliancejhall is offline
Friend of Wrox
Points: 788, Level: 10
Points: 788, Level: 10 Points: 788, Level: 10 Points: 788, Level: 10
Activity: 15%
Activity: 15% Activity: 15% Activity: 15%
 
Join Date: Nov 2007
Location: Central Florida, USA.
Posts: 199
Thanks: 2
Thanked 15 Times in 15 Posts
Default You could do...

something like?

Code:
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click

        If FileUpload1.HasFile Then
            Try
                If System.IO.File.Exists("C:\test\" & FileUpload1.FileName) Then
                    lbl1.text = "file exsists try another"
                Else
                    FileUpload1.SaveAs("C:\test" & _
                    FileUpload1.FileName)
                End If
            Catch ex As Exception
                FileUploadReport.Text = "Faild Because:<br/>" & ex.Message
            End Try
                FileUploadReport.Text = "File uploaded : <br/>" & FileUpload1.PostedFile.FileName
        Else
            FileUploadReport.Text = "Please select a file before clicking" & " the 'Upload' button"
        End If

    End Sub
__________________
Jason Hall
Reply With Quote