我想使用VB.NET将文件夹重命名为当前日期和时间
Dim thisDate As Date
thisDate = Today
My.Computer.FileSystem.RenameDirectory(Destination, "Backup_" & Today)
答案 0 :(得分:0)
使用它:
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If String.IsNullOrEmpty(Source) OrElse String.IsNullOrEmpty(Destination) Then
MsgBox("Source and Destination cant be empty")
Exit Sub
End If
My.Computer.FileSystem.CopyDirectory(Source, Destination, True)
Dim DestinationBackup As String = "C:\temp"
Dim NewDir As String = System.IO.Path.Combine(DestinationBackup, "Backup_" & DateTime.Now.ToString("yyyyMMddHHmmssfffff"))
If System.IO.Directory.Exists(NewDir) Then
System.IO.Directory.Delete(NewDir, True)
End If
System.IO.Directory.Move(Destination, NewDir)
End Sub
答案 1 :(得分:0)
尝试使用此
date.now().tostring("yyyyMMdd")