Windows文件系统:当删除并再次创建文件时,文件的创建时间不会更
发布时间:2020-12-13 20:15:23 所属栏目:Windows 来源:网络整理
导读:我有以下情况: 1:创建一堆文件 2:调用一些外部应用程序来处理所有不同的文件 自上次快照以来的创建时间 3:删除文件 4:goto 1 原来,Windows不能保证在用户创建文件时会删除创建时间,而是创建一个具有相同名称的文件. 我写了一个小型的PowerShell脚本来验
我有以下情况:
> 1:创建一堆文件 原来,Windows不能保证在用户创建文件时会删除创建时间,而是创建一个具有相同名称的文件. 我写了一个小型的PowerShell脚本来验证这一点: ls | Remove-Item $fileListOld = @{} foreach($i in 1..1000) { $fname = [string]::Format("{0}.txt",$i) "tst" >> $fname } ls | % { $fileListOld[$_.Name] = $_ } ls | Remove-Item foreach($i in 1..1000) { $fname = [string]::Format("{0}.txt",$i) "tst" >> $fname } $fileListNew = @{} ls | % { $fileListNew[$_.Name] = $_ } $count = 0 foreach ($fname in $fileListNew.Keys) { if ($fileListNew[$fname].CreationTimeUtc -eq $fileListOld[$fname].CreationTimeUtc) { Write-Host Same creation time -ForegroundColor Red Write-Host $fname -ForegroundColor Red $count++ } } Write-Host $count 输出: ... ... Same creation time 241.txt Same creation time 944.txt Same creation time 908.txt Same creation time 631.txt Same creation time 175.txt Same creation time 798.txt Same creation time 192.txt Same creation time 961.txt Same creation time 476.txt Same creation time 566.txt Same creation time 945.txt Same creation time 681.txt Same creation time 880.txt Same creation time 162.txt Same creation time 634.txt Same creation time 746.txt Same creation time 442.txt Same creation time 35.txt Same creation time 96.txt Same creation time 771.txt Same creation time 787.txt Same creation time 972.txt Same creation time 642.txt Same creation time 495.txt Same creation time 625.txt Same creation time 666.txt Same creation time 660.txt Same creation time 6.txt Same creation time 593.txt Same creation time 549.txt Same creation time 842.txt Same creation time 314.txt Same creation time 148.txt **1000** 如果我睡了一段时间(> 30秒),删除后所有的文件将有正确的时间戳. 有没有办法解决这个问题?一些winapi调用删除文件好吗?
我相信你在Windows中遇到了一个现象,就是
filesystem tunneling.这是基于NT的系统的一个功能,其中与同一目录中最近删除的文件具有相同名称的新文件将会继承旧文件的创建时间.
您可以禁用隧道或更改旧文件数据被缓存的时间长度.详见Microsoft KB article. 文件系统隧道被实现,因为许多应用程序将删除和重新创建他们希望改变的文件,而不仅仅是更新它们. 您应该能够使用@Jim Rhodes建议来抵消此功能. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 为什么Eigen不需要链接.lib或dll?
- slice :: chunks / windows是否有等效的迭代器循环对,三元组
- 分区 – Server 2012 Core(无GUI) – 如何管理磁盘?
- 我在哪里可以获得Windows检查版本?
- Windows上的Python 3.4中的Tkinter在退出时不会将内部剪贴板
- Windows 2012 R2 中的AD DS部署
- windows – 我可以在Access应用程序中使用Active Directory
- Microsoft Word中格式化的PHP代码
- [转帖]Ansible管理windows集群
- windows charles response 乱码解决办法