I don't see anything wrong with the code that you show, so I have two
questions:
1. Are you SURE the error is in the For Each line?
2. If not, what code is inside the loop?
I will admit that the only time I have ever used the HttpPostedFile class is
when uploading a file from an HtmlControls.HtmlInputFile control, but your
code looks correct based on the documentation I found. However, I have seen
situations where the errors tell you the problem is in a line other than the
one it is in (whether that is the case here, I can't say because I haven't
seen the code you have inside the loop), so one thing I might try is testing
each line individually not inside a loop by replacing oFile with
Request.Files(0). If you don't get any errors doing this, put it back inside
the loop and add an extra output line or use a debugger to determine the
value of oFile during each loop cycle. You may also want to post the code
inside the loop so that others can check that as well. Good Luck!
--
Nathan Sokalski
http://www.nathansokalski.com/
"MSDN" <> wrote in message
news:...
> Does anyone know why I am getting Invalid cast exception???
>
> For Each oFile As System.web.HttpPostedFile In Request.Files
>
> ...... etc.....
>
> Next
>
> I Checked that
>
> Request.Files(0).GetType.tostring = "System.web.HttpPostedFile"
>
> So what is the issue here??? I can just use a loop but ....
>
> Thanks,
>
> SA
>
>
>
>
>
>