当我打开我的文件写一些东西时,我得到了“权限被拒绝”。
Dim CustomDriveIcon As String CustomDriveIcon = "CustomDriveIcon_" & txtDrive.Text & ".reg" Dim newFIle Dim FSO Set FSO = CreateObject("Scripting.FileSystemObject") Set newFIle = FSO.CreateTextFile(CustomDriveIcon)
的DoEvents
Dim sFileText As String
Dim iFileNo As Integer
iFileNo = FreeFile
Open CustomDriveIcon For Output As #iFileNo
Print #iFileNo, "Windows Registry Editor Version 5.00"
Print #iFileNo, ""
Print #iFileNo, "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\C\DefaultIcon]"
Print #iFileNo, "@=" & Chr(34) & "\" & Chr(34) & txtIconPath & "\" & Chr(34) & Chr(34) '@="\"C\""
Close #iFileNo
我在问题“Open CustomDriveIcon For Output As #iFileNo
”上遇到了错误吗?
答案 0 :(得分:3)
您已使用CreateTextFile打开文件两次,使用Open语句打开一次。您无法打开文件两次,因此第二次失败。
只需删除这些行 - 您不需要它们。
Dim newFIle Dim FSO
Set FSO = CreateObject("Scripting.FileSystem Object")
Set newFIle = FSO.CreateTextFile(CustomDriveIcon )