Do You Have Access To A Drive Without Opening A File On That Drive

Assume that you have the full path name of a file, and you need to beable to tell if the drive is writeable (that is, if it is a CD-ROM or anetwork drive to which you have write access). Checking the attributesof the file is not enough, because the file may not be marked read-only,but the drive may be a read-only drive. However, if you open the file forWrite or Append inside VB, it will reset the file’s date stamp, which youdon’t want.To determine if a file is writeable without writing to it, get the attributesof the file with GetAttr, and then attempt to change them with SetAttr.This operation will fail if you do not have write permission on the drive.On the other hand, if you are worried about a file being locked for writing(like an EXE is while it is running under Windows), you should use theOpenFile() API call with the OF_WRITE switch. This call will generate anerror if the file cannot be opened for writing, but will not change thetime stamp if you simply close it right away.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: