Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 6, 1997

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 be able to tell if the drive is writeable (that is, if it is a CD-ROM or a network drive to which you have write access). Checking the attributes of 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 for Write or Append inside VB, it will reset the file's date stamp, which you don't want. To determine if a file is writeable without writing to it, get the attributes of 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 the OpenFile() API call with the OF_WRITE switch. This call will generate an error if the file cannot be opened for writing, but will not change the time stamp if you simply close it right away.
A. Nicklas
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap