Checking if can write to a drive

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Trying to check if a drive is writable. Can do it by trying to create a directory using DirectoryInfo class then checking err.number but looking for a more elegant way. Tried DirectoryInfo.Attributes.ReadOnly but always get a FileAttributes.ReadOnly result. Any help would be appreciated.
 
The simplest way is trying to create a temporary file using something like:

File.Create(pathToTest + Guid.Create()+".tmp")

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Dennis said:
Trying to check if a drive is writable. Can do it by trying to create a
directory using DirectoryInfo class then checking err.number but looking for
a more elegant way. Tried DirectoryInfo.Attributes.ReadOnly but always get
a FileAttributes.ReadOnly result. Any help would be appreciated.
 
Back
Top