Ruby Get Available Disk Drives

半腔热情 提交于 2019-12-07 02:44:20

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/3258518/ruby-get-available-disk-drives

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!