創建不會改變我有以下情形:的Windows文件系統:一個文件的創建時間而被刪除並重新
1:創建一批文件
2:召喚處理與不同 創建時的所有文件自上次快照
3的一些外部應用程序:刪除文件
4:1轉到
原來的窗戶不能保證當用戶創建一個文件,刪除它,它會改變創建時間比創建一個具有相同名稱的文件。
我寫了一個小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調用刪除文件好?
這就是所謂的「隧道」。有關更多詳細信息,請參見[本知識庫文章](http://support.microsoft.com/?kbid=172190)。 (該文件已被刪除,只是創建時間和正在傳輸的其他元數據。) – 2012-01-10 15:38:04
@RaymondChen,閱讀我收集的這幾行內容,這是爲了保留使用短文件名的程序的長文件名? – 2012-01-10 21:33:09
那是它的一部分。但也適用於使用創建/重命名/刪除技巧替換文件的應用程序。這將元數據從舊文件傳播到新文件。 – 2012-01-10 21:59:28