Is there a simple way to get the FileInfo object from an HttpPostedFileBase? I realize I can save the file then do something like DirectoryInfo.GetFiles and then loop through the files looking for my file, but is there any simpler way to do this for a given file?
Is there a simple way to get the FileInfo object from an HttpPostedFileBase ?
Share
There’s no
FileInfoassociated to an uploaded file. Only thefilenameis sent as parameter as well as the file stream itself. So that’s what you could query:To better understand what gets sent from the client I invite you to read the
multipart/form-dataspecification.The FileInfo object contains things like LastModified and LastAccessed date which is not an information that is sent when a file is uploaded. If you save the file on your web server disk and then retrieve the FileInfo from it bear in mind that what you will be retrieving is the information about this file on the server and not on the client simply because this information is never sent when a file is uploaded.