谁能告诉我如何获得 ruby 中可用磁盘驱动器的列表?我正在创建一个打开的文件对话框,需要知道!提前谢谢,嗯。
问问题
3517 次
1 回答
12
Brian 给出的文章正确地说明了以下代码:
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
于 2010-07-15T18:47:33.550 回答