我有以下的代碼,檢查臨時文件夾的文件大小,另一個是刪除它們:刪除舊的(24小時)以前的VB.NET?
TemporaryFilesSize.Text = 0
For Each foundFile As String In My.Computer.FileSystem.GetFiles(_
My.Computer.FileSystem.SpecialDirectories.Temp, _
Microsoft.VisualBasic.FileIO.SearchOption.SearchAllSubDirectories, "*.*")
Dim filesizeinbytes As System.IO.FileInfo = My.Computer.FileSystem.GetFileInfo(foundFile)
TemporaryFilesSize.Text = TemporaryFilesSize.Text + filesizeinbytes.Length
Next
'Changing From Bytes To Mb Gb ...
Dim filesizeunit As String = ""
If TemporaryFilesSize.Text >= 1024 Then
filesizeunit = "Kb"
TemporaryFilesSize.Text = TemporaryFilesSize.Text/1024
If TemporaryFilesSize.Text >= 1024 Then
filesizeunit = "Mb"
TemporaryFilesSize.Text = TemporaryFilesSize.Text/1024
If TemporaryFilesSize.Text >= 1024 Then
filesizeunit = "Gb"
TemporaryFilesSize.Text = TemporaryFilesSize.Text/1024
Else
End If
Else
End If
Else
filesizeunit = "Bytes"
End If
Dim filesize As Double = TemporaryFilesSize.Text
filesize = Math.Round(filesize, 2)
TemporaryFilesSize.Text = filesize
TemporaryFilesSize.Text = TemporaryFilesSize.Text & filesizeunit
有沒有辦法讓我的代碼得到的大小或刪除創建更24小時之前文件。
我已經找到了計算器,但在Java,PHP和許多答案...
的[FileInfo的](https://msdn.microsoft.com/en-us/library/system.io.fileinfo(V = vs.110)的.aspx)類有你需要的信息。 –