boy11-2 发表于 2011-02-18 02:04

Ruby 打开 Windows 的文件对话框

require "win32ole"

cd = WIN32OLE.new("MSComDlg.CommonDialog")

cd.filter = "All Files(*.*)|*.*" +"|Ruby Files(*.rb)|*.rb"
cd.filterIndex = 2

cd.maxFileSize = 128    # Set MaxFileSize

cd.showOpen()

file = cd.fileName      # Retrieve file, path

if not file or file==""
   puts "No filename entered."
else
   puts "The user selected: #{file}\n"
end

2gua 发表于 2011-02-18 08:52

楼主搞个系列帖吧。
页: [1]
查看完整版本: Ruby 打开 Windows 的文件对话框