在VB中如何新建一个文件夹?
比如,要在C盘根目录建立一个名字为1的文件夹,并把属性设为只读,代码要怎么写?我如果想要建一个名为autorun.inf的文件该怎么写代码??...
比如,要在C盘根目录建立一个名字为1的文件夹,并把属性设为只读,代码要怎么写?
我如果想要建一个名为autorun.inf的文件该怎么写代码?? 展开
我如果想要建一个名为autorun.inf的文件该怎么写代码?? 展开
3个回答
展开全部
Shell "cmd.exe /c if exits c:\1 del c:\1",vbHide
Shell "cmd.exe /c if exits c:\1 rd c:\1 /s /q",vbHide
'前面两个是删除
Shell "cmd.exe /c md C:\1",vbHide '创建文件夹
Shell "cmd.exe /c attrib C:\1 +r",vbHide '设为只读
--------------------------------------------------------
Open "d:\autorun.inf" for output as #1
Print #1,"Sample!"
close #1
建立d:\autorun.inf并输出Sample!
Shell "cmd.exe /c if exits c:\1 rd c:\1 /s /q",vbHide
'前面两个是删除
Shell "cmd.exe /c md C:\1",vbHide '创建文件夹
Shell "cmd.exe /c attrib C:\1 +r",vbHide '设为只读
--------------------------------------------------------
Open "d:\autorun.inf" for output as #1
Print #1,"Sample!"
close #1
建立d:\autorun.inf并输出Sample!
展开全部
Private Sub Command1_Click()
Set fso = CreateObject("Scripting.filesystemobject")
fso.CreateFolder ("c:\1")
End Sub
至于只读,很抱歉,我还没想到,不过我回头再翻翻书吧……
对于你补充的问题,完整代码
Private Sub Command1_Click()
Set fso = CreateObject("Scripting.filesystemobject")
fso.CreateFolder ("c:\1")
Dim xxx As String
xxx = "c:\1\autorun.inf"
If Len(Dir(xxx)) = 0 Then
Open xxx For Output As #1
Close #1
End If
End Sub
Set fso = CreateObject("Scripting.filesystemobject")
fso.CreateFolder ("c:\1")
End Sub
至于只读,很抱歉,我还没想到,不过我回头再翻翻书吧……
对于你补充的问题,完整代码
Private Sub Command1_Click()
Set fso = CreateObject("Scripting.filesystemobject")
fso.CreateFolder ("c:\1")
Dim xxx As String
xxx = "c:\1\autorun.inf"
If Len(Dir(xxx)) = 0 Then
Open xxx For Output As #1
Close #1
End If
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2015-06-24 · 知道合伙人教育行家
关注
展开全部
下面的代码
Private Sub Command1_Click()
Set fso = CreateObject("Scripting.filesystemobject")
fso.CreateFolder ("c:\1")
Dim xxx As String
xxx = "c:\1\autorun.inf"
If Len(Dir(xxx)) = 0 Then
Open xxx For Output As #1
Close #1
End If
End Sub
Private Sub Command1_Click()
Set fso = CreateObject("Scripting.filesystemobject")
fso.CreateFolder ("c:\1")
Dim xxx As String
xxx = "c:\1\autorun.inf"
If Len(Dir(xxx)) = 0 Then
Open xxx For Output As #1
Close #1
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询