-1

I have a MVC web application, which provides users to upload text files. I then take those text files and store it on a folder which is monitored by a file system watcher and in turn upon newly generated files, it transfers those files to an FTP server. Everything works great but there is a small issue with File Creation Dates. I noticed that when they upload the file to my web application, the original file creation date is replaced by the current date (the time when the file is actually uploaded). This does not happen on my local machine. Before I save the file I even try to get the file creation date but its always wrong. Could it be a server configuartion setting? My requirement is to take the original file creation date and convert that to an epoch date in milliseconds. Again, locally on dev machine it works great, just on the server it overrides the original creation date. Below is my code:

 string storedFileName = string.Format("{0}{1}.out", destinationPath, System.Guid.NewGuid());
                            file.ElementAt(1).SaveAs(storedFileName);

                            DateTime fileCreatedDate = System.IO.File.GetCreationTime(file.ElementAt(1).FileName);

                            //Change Creation DateTime to Epoch
                            TimeSpan span = (fileCreatedDate - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime());
                            double epoch = span.TotalMilliseconds;
4

1 回答 1

1

不。

作为 HTTP 文件上传的一部分,没有包含有关文件的元数据。你能得到的最多的是文件名,有时是路径。

如果您需要获取其他文件信息,则需要创建某种客户端应用程序来执行自定义上传。单独的浏览器也不会为您的脚本提供此类信息。

于 2012-11-09T17:28:01.857 回答