views:

58

answers:

1
+4  Q: 

ASP.NET FileUpload

Greetings!

I am using the ASP.NET FileUpload control to allow users to upload text files to our web server. Everything works great in terms of saving the file to where we wanted, etc, using the SaveAs() method of the control.

But we were caught off guard by one seemingly simple caveat: the original timestamp of the uploaded file was lost such as the date last modified and date create. The date last modified and date created become the actual date and time when the file is saved to the server.

My question is: is there anyway to retain the original timestamp by setting some attributes that I am not aware of yet or is it possible to read the metadata of the file to get its original time stamp?

Any in-sight and suggestions are greatly appreciated.

John

+1  A: 

Unless the file format being uploaded itself contains this data, then no.

When a file is uploaded to a web server, the binary data for the file is sent to the server, not the "file" as it is represented in the filesystem. You don't, for example, know that your file is coming from a compatible filesystem; you only get its data. Hence, the metadata is inaccessible.

Martin Eve
Thanks Martin for the quick and definite answer. I have learned since my post that the only way to get that information is through silverlight, or javaapplet or activeX Control that can access client file system.
John
No problem; obviously, these solutions come with the additional burden of your user having to grant the applet permission to access the local filesystem, but if you really need the data, that's the way to go.
Martin Eve
You are absolutely right. Exactly because of the reason you described we decided not to bother with the timestamp of an uploaded file. We have to live within limits.
John