PDA

Click to See Complete Forum and Search --> : Trouble Uploading


venerable bede
Nov 27th, 2003, 10:40 AM
I use the following code to handle an uploaded file :

If Not IsNothing(MyFile.PostedFile) Then
Dim filepath1 As String = Path.Combine(Path.GetTempPath), "mycvstuff.txt")
Dim strfilename As String = MyFile.PostedFile.FileName
c = System.IO.Path.GetFileName(strfilename)
Try
MyFile.PostedFile.SaveAs("C:\Documents and Settings\All Users\cvdocs\" & c)
Catch Exc As Exception
Me.Label1.Text = Exc.ToString
End Try
End If

The problem is that even when the user has not uploaded a file the code executes producing an error.
If Not IsNothing(MyFile.PostedFile) doesnt seem to work.

Any Ideas what I'm doing wrong. When I choose a file to upload it works fine.

TIA