views:

242

answers:

2

Hi all,

I've got an asp.net mvc application that uploads a file and stores them in one of the directories where the website is located.

My question is... When you execute HttpPostedFileBase.SaveAs() method saving it with the same name as an existing filename on the folder, does HttpPostedfileBase overwrite the file?

Thanks a million!

+1  A: 

Yes. Any existing file will be overwritten. (I checked the source)

SLaks
Thank you for answering my question. Was wondering which reference source did say that it does overwrite the file? Would appreciate it if you could point me where it is.Thanks again!
mallows98
`System.Web.HttpPostedFile` in `System.Web.dll`. The only implementation of `HttpPostedFileBase` is a thin wrapper around it. (You can see this in Reflector)
SLaks
+1  A: 

HttpPostedFileBase is just an abstract base class - what SaveAs does depends on the implementation. However, it's clearly meant to abstract HttpPostedFile, and that will overwrite any files at the target location - if it can (i.e. has the appropriate permissions).

Eamon Nerbonne