Vbscript 是否覆盖visual basic脚本中的文件夹?
我正在研究一种方法来覆盖一个文件夹,如果它已经存在,并得到确认。这是我的代码和我一直坚持的部分:Vbscript 是否覆盖visual basic脚本中的文件夹?,vbscript,wsh,fso,Vbscript,Wsh,Fso,我正在研究一种方法来覆盖一个文件夹,如果它已经存在,并得到确认。这是我的代码和我一直坚持的部分: Set fso = CreateObject("Scripting.FileSystemObject") Set shell = CreateObject("WScript.Shell") Set network = CreateObject("WScript.Network") username = network.userName us
Set fso = CreateObject("Scripting.FileSystemObject")
Set shell = CreateObject("WScript.Shell")
Set network = CreateObject("WScript.Network")
username = network.userName
userprofile = shell.ExpandEnvironmentStrings("%userprofile%")
If fso.FolderExists(userprofile + "\foldername") = False Then
fso.CreateFolder(userprofile & "\foldername")
End If
If fso.FolderExists(userprofile + "\foldername") = True Then
overwrite = msgbox("The directory that foldername uses(" & userprofile + "\foldername) is unavailable. Overwrite?",4+16+4096,"")
if overwrite = vbYes then
overwrite2 = msgbox("THIS IS YOUR LAST WARNING. Any files in " & userprofile + "\foldername will be PERMANENTLY LOST. Continue?",4+16+4096,"")
if overwrite2 = vbYes then
'overwriting folder goes here
End If
if overwrite2 = vbNo then
End If
if overwrite = vbNo then
End If
覆盖文件夹在这里,我需要帮助。谢谢 当您说覆盖文件夹是指删除所有现有内容?如果是这样,你能先删除文件夹,然后再重新创建吗
if overwrite2 = vbYes then
strFolderPath = userprofile & "\foldername"
fso.DeleteFolder strFolderPath, true
fso.CreateFolder(strFolderPath)
End If
你有没有试着看而不是好奇如果指定的文件夹已存在,则会发生错误。是,实际上是。这个问题我已经查了几十遍了,查看了所有的官方文档,以及如何创建文件夹的示例,但我总是得到CopyFolder结果,这对我来说不起作用。当你说覆盖文件夹是指删除所有现有内容时?是的。但是我找不到这方面的帖子。