在VB中刪除文件夾下所有文件可以使用以下代碼:
Dim folderPath As String
folderPath = "C:\path\to\folder"
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
Dim folder As Object
Set folder = fs.GetFolder(folderPath)
Dim file As Object
For Each file In folder.Files
fs.DeleteFile file.Path
Next file
這段代碼首先獲取指定文件夾的路徑,然后創建一個FileSystemObject對象來操作文件系統。接著獲取文件夾對象并遍歷文件夾下的所有文件,使用DeleteFile方法刪除每個文件。