gpt4 book ai didi

vb.net - 使用 VB.net 自动执行任务

转载 作者:可可西里 更新时间:2023-11-01 09:29:05 26 4
gpt4 key购买 nike

我有这段代码可以自动备份文件夹,而且效果很好。然而,我想让它在每天中午 12 点之前自动备份,从而提​​高它的档次。非常感谢 Ant 提供有关如何解决此问题的提示。

Imports System.IO
Imports System.IO.Compression
Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim dstr As String
Dim mstr As String
Dim ystr As String
Dim folstr As String
Dim dsumstr As String

dstr = DateTime.Today.ToString("dd")
mstr = DateTime.Today.ToString("MM")
ystr = DateTime.Today.ToString("yyyy")
dsumstr = ystr & "-" & mstr & "-" & dstr
folstr = "Y:\server1\Fileserver-" & dsumstr
Try
My.Computer.FileSystem.CreateDirectory(folstr)

My.Computer.FileSystem.CreateDirectory(folstr & "\SHARE-AC")
My.Computer.FileSystem.CopyDirectory("D:\SHARE-AC", folstr & "\SHARE-AC")



Label1.Text = "Back up DATE " & dsumstr & " Complete"
Catch ex As Exception
Label1.Text = (ex.Message)
End Try

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
End Class

最佳答案

对于我们的 Windows 服务器,我们使用任务计划程序。您可以阅读更多 here .

enter image description here

关于vb.net - 使用 VB.net 自动执行任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21931330/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com