Thread: File upload
View Single Post
  #6 (permalink)  
Old January 9th, 2009, 03:39 AM
bex bex is offline
Friend of Wrox
Points: 643, Level: 9
Points: 643, Level: 9 Points: 643, Level: 9 Points: 643, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 153
Thanks: 7
Thanked 1 Time in 1 Post
Default

No I am not adding test to the filename i just want to upload it under test directory under c:\
the actual code is like this:
Code:
ProtectedSub Button1_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles btnUpload.Click
If FileUpload1.HasFile Then
Try
If System.IO.File.Exists("C:\test\" & FileUpload1.FileName) Then
FileUploadReport.Text = "file exsists try another"
Else
FileUpload1.SaveAs("C:\test\" & FileUpload1.FileName)
EndIf
Catch ex As Exception
FileUploadReport.Text = "Faild Because:<br/>" & ex.Message
EndTry
FileUploadReport.Text = "File uploaded : <br/>" & FileUpload1.PostedFile.FileName
Else
FileUploadReport.Text = "Please select a file before clicking" & " the 'Upload' button"
EndIf

__________________
bx
Reply With Quote