vb创建文件的问题,跪求高手啊,帮帮忙啊

tunder110 2013-03-13 04:49:52
用下面的代码,在nflag文件夹不存在时可以创建nflag,并且在他下面可以创建多个*.ini,可是当我把nflag下的ini文件删除后,再运行时,怎么又进If Dir(App.Path & "\nflag\") = "" Then
里面了,人后到mkdir就报错了。报
error '75'Path/File access error,求高手帮看看,哪有问题

'读取循环记数器



'判断nflag文件夹是否存在,不存在自动建立
If Dir(App.Path & "\nflag\") = "" Then
MkDir (App.Path & "\nflag\")
End If

nflagfile = App.Path & "\nflag\" & DevID & ".ini"

'判断循环计数器文件是否存在,若不存在自动建立并初始化
If Dir(nflagfile) = "" Then
Open nflagfile For Output As #1
Print #1, "1"
Close #1
End If

Open nflagfile For Input As #1
nflag = StrConv(InputB$(LOF(1), 1), vbUnicode)
Close #1

...全文
558 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
tunder110 2013-03-13
  • 打赏
  • 举报
回复
引用 6 楼 c0631106233 的回复:
If Dir(App.Path & "\nflag", vbDirectory) = "" Then
问题解决了,这才是正解
酷心 2013-03-13
  • 打赏
  • 举报
回复
If Dir(App.Path & "\nflag", vbDirectory) = "" Then
咸清 2013-03-13
  • 打赏
  • 举报
回复
If Dir(App.Path & "\nflag") = "" Then MkDir (App.Path & "\nflag") End If 这样试试
  • 打赏
  • 举报
回复
不懂啊
  • 打赏
  • 举报
回复
错误的意思是读写文件时路径和文件名找不到,或因文件路径读写许可不允许而不让读写。
  • 打赏
  • 举报
回复
Path/File access error During a file-access or disk-access operation, the operating system could not make a connection between the path and the file name. To correct this error 1. Make sure the file specification is correctly formatted. A file name can contain a fully qualified (absolute) or relative path. A fully qualified path starts with the drive name (if the path is on another drive) and lists the explicit path from the root to the file. Any path that is not fully qualified is relative to the current drive and directory. 2. Make sure that you did not attempt to save a file that would replace an existing read-only file. If this is the case, change the read-only attribute of the target file, or save the file with a different file name. 3. Make sure you did not attempt to open a read-only file in sequential Output or Append mode. If this is the case, open the file in Input mode or change the read-only attribute of the file. 4. Make sure you did not attempt to change a Visual Basic project within a database or document
tunder110 2013-03-13
  • 打赏
  • 举报
回复
求高手指点下啊

7,765

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧