How to Access in App.Path?
When I run this co开发者_StackOverflow社区de in VB, the VB said me "Patch file access error". Can anybody help me? Here is my code:
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
I would suggest that your process doesn't have the necessary permissions on the path to create a directory? By default Users do have modify privileges on c:\Users
You can get this issue on Windows 7 if you haven't elevated your process using Run As Administrator
. This is true for the VB6 IDE as well as this doesn't run as admin by default.
If you try to create (MkDir) a directory that already exists you will get an error 75, Path/File access error. You need to modify your code to check for the directory and create it only if it does not exist.
If Len(Dir(App.Path & "\users" & Splice(2)) = 0 Then
MkDir App.Path & "\users" & Splice(2)
End If
etc.
精彩评论