Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby Get Available Disk Drives

Can anyone tell me how I can get a list of the available disk drives in ruby? I am creating an open file dialogue and need to know! Thanks in advance, ell.

like image 682
Ell Avatar asked Jul 15 '10 18:07

Ell


1 Answers

The article Brian gave correctly states the following code:

require 'win32ole'

file_system = WIN32OLE.new("Scripting.FileSystemObject")
drives = file_system.Drives
drives.each do |drive|
  puts "Available space: #{drive.AvailableSpace}"
  puts "Drive letter: #{drive.DriveLetter}"
  puts "Drive type: #{drive.DriveType}"
  puts "File system: #{drive.FileSystem}"
  puts "Is ready: #{drive.IsReady}"
  puts "Path: #{drive.Path}"
  puts "Root folder: #{drive.RootFolder}"
  puts "Serial number: #{drive.SerialNumber}"
  puts "Share name: #{drive.ShareName}"
  puts "Total size: #{drive.TotalSize}"
  puts "Volume name: #{drive.VolumeName}"
end
like image 177
Ell Avatar answered Oct 23 '22 11:10

Ell