FileReceived question

Aug 25, 2009 at 4:11 AM

I am using the FileReceived event to RENAME the uploaded file and copy it to another directory.  I noticed that this runs, of course, after the file has been uploaded.

I'm dealing with 1-2GB files so it takes extra time.  Any way to rename the file and upload it DIRECTLY to a custom directory without having to do it thru FileReceived?

Secondly, I also noticed that the FileReceived event ran TWICE even though I only uploaded one file.  (Thus it creates 2 copies of the file in Upload dir.)  Any ideas why?

Here's the code...

Protected Sub FileUploader1_FileReceived(ByVal sender As Object, ByVal e As com.flajaxian.FileReceivedEventArgs) Handles FileUploader1.FileReceived
            Dim fname As String = Server.MapPath(".") & "\Upload\" & Now.Millisecond.ToString & "." & e.File.FileName.Split(".")(1)
            Dim msg As String = e.File.FileName & " uploaded to " & fname & " at " & Now.ToString
            lblStatus.Text = msg

            System.IO.File.Delete(Server.MapPath(".") & "\UploadTemp\" & e.File.FileName)
        Catch ex As Exception
            lblStatus.Text = ex.ToString
        End Try
    End Sub


Awesome product!