如何在App.Path中访问?

时间:2011-07-28 17:37:09

标签: vb6

当我在VB中运行此代码时,VB称我“修补程序文件访问错误”。有谁能够帮我?这是我的代码:

MkDir App.Path & "\users\" & Splice(2)
Open App.Path & "\users\" & Splice(2) & "\pass.txt" For Append As #1
Print #1, Splice(3)
Close #1
MkDir App.Path & "\users\" & Splice(2)
Open App.Path & "\users\" & Splice(2) & "\list.txt" For Append As #1
Print #1, "" 'we have to put something into the buddy list
                 'so well put nothing ;)
Close #1
MkDir App.Path & "\users\" & Splice(2)
Open App.Path & "\users\" & Splice(2) & "\info.txt" For Append As #1
Print #1, "" 'we have to put something into the buddy list
                 'so well put nothing ;)
Close #1
MkDir App.Path & "\users\" & Splice(2)
Open App.Path & "\users\" & Splice(2) & "\ipreglog.log" For Append As #1
Print #1, inip
Close #1

2 个答案:

答案 0 :(得分:2)

我建议您的进程在创建目录的路径上没有必要的权限?默认情况下,用户对c:\ Users

具有修改权限

如果您未使用Run As Administrator提升流程,则可以在Windows 7上遇到此问题。对于VB6 IDE也是如此,默认情况下这不会以管理员身份运行。

答案 1 :(得分:1)

如果您尝试创建(MkDir)已存在的目录,则会收到错误75,路径/文件访问错误。您需要修改代码以检查目录,并仅在目录不存在时创建它。

If Len(Dir(App.Path & "\users" & Splice(2)) = 0 Then
    MkDir App.Path & "\users" & Splice(2)
End If