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;