简体   繁体   English

写入/还原二进制文件流时,保存文件的创建/修改日期

[英]Saving create / modify dates of file when writing / restoring a binary filestream

Is it possible to save a file's original create / modify dates when saving a file to a db (via filestream & BinaryReader) and then have those dates attached to the file when recreating the file, again via filestream & BinaryWriter, from the db? 是否可以在将文件保存到数据库时(通过filestream和BinaryReader)保存文件的原始创建/修改日期,然后从数据库重新创建文件时再次通过filestream和BinaryWriter将这些日期附加到文件上? If possible, how do I do it? 如果可能,我该怎么办?

My inital research leads me to believe only the file contents are being stored and retrieved. 我的初步研究使我相信只有文件内容会被存储和检索。

You can add database columns for the data you want to save about your file. 您可以为要保存的有关文件的数据添加数据库列。 When you write a file to the database, put this information into the columns. 当您将文件写入数据库时​​,请将此信息放入列中。 When you read, change file properties according to the data from columns. 读取时,根据列中的数据更改文件属性。

As suggested by Athari you can store those times in database columns and when you are recreating the file use System.IO.FileInfo. 根据Athari的建议,您可以将这些时间存储在数据库列中,并在重新创建文件时使用System.IO.FileInfo。 You can set all the time properties using this. 您可以使用此设置所有时间属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM