- let metadata = new Metadata (cryptoStream)
-
- // Create the file and write.
- let filename = metadata.get Metadata.filename
- use outputStream = new FileStream (Path.Combine (targetDirPath, filename), FileMode.Create, FileAccess.Write)
- cryptoStream.CopyTo outputStream
- ()
+ let metadata = Metadata cryptoStream
+
+ // Create the file and write its content and metadata.
+ let filePath = Path.Combine (targetDirPath, metadata.get MetadataKeys.filename)
+ let modificationTime = DateTime (metadata.get MetadataKeys.modificationTime |> int64)
+ let fileInfo = FileInfo filePath
+ using (fileInfo.Create ()) cryptoStream.CopyTo // We have to close the result file before updating the modification time.
+ fileInfo.LastWriteTimeUtc <- modificationTime
+
\ No newline at end of file