VS2005中,access对只读目录的属性判断不准确

来源:互联网 发布:水流量计算软件 编辑:程序博客网 时间:2024/05/06 05:31

只读目录,
C:/>attrib +A +S +H +R testdir
C:/>attrib testdir
A  SHR     C:/testdir

 

(1)VC6.0的执行结果:
***********test stat***********************
file [c:/testdir] exists!
file [c:/testdir] is directory!
file [c:/testdir] can be read!
file [c:/testdir] can not be writed!

***********test access***********************
file [c:/testdir] exists!
file [c:/testdir] can not be writed!
file [c:/testdir] can be read!

 

(2)VS2005的执行结果
***********test stat***********************
file [c:/testdir] exists!
file [c:/testdir] is directory!
file [c:/testdir] can be read!
file [c:/testdir] can not be writed!

***********test access***********************
file [c:/testdir] exists!
file [c:/testdir] can be writed!
file [c:/testdir] can be read!

 

结论:在VS2005中,使用access判断的只读目录却有【写入】的属性。

         有什么高招,欢迎解答。


建议,在VS2005中对文件、目录进行权限校验时,最好不要用access。

 

原创粉丝点击