From: Siep Korteling Date: 2010-02-12T07:26:03+09:00 Subject: Re: Can SWIN CommonDialog.openFilename() select multiple files? Chris Hulan wrote: > On Feb 11, 10:32�am, Alex DeCaria > wrote: >> Can the SWIN CommonDialog.openFilename() method be used to select >> multiple filenames at one time? >> > > Had to look at the code but looks like it is a straight forward > wrapper of the CommonDialog:GetOpenFileName (http://msdn.microsoft.com/ > en-us/library/ms646829(VS.85).aspx#open_file) > so supports all its functionality > Set the OFN_ALLOWMULTISELECT flag, and the result should be a string > containing all the files. > The windows doc says it could be NULL separated or space separated so > you'll need to play a bit to figure out > how to parse out the individual file names. > > This is all based on reading, so while in theory its correct, in > practice you'll have to figure some stuff out ;) > > cheers > Chris I'm also trying to figure this out. The best I have so far is: OFN_EXPLORER = 0x00080000 OFN_ALLOWMULTISELECT = 0x00000200 #(...)lots of other constants require 'swin' filetype_filter = [['Ruby files (*.rb)','*.rb'], ['All files (*.*)', '*.*']] paths = SWin::CommonDialog::openFilename( nil, filetype_filter, OFN_ALLOWMULTISELECT, 'Choose one or more files.') puts paths Which looks like a horrible blast from the past: windows 3.1! It works, but the result looks like this: "D:\\projects\\test\\ autoit_test.rb binomial.rb" And what if the filename contains a space? Ah yes, of course, short filenames. "D:\\projects\\test\\ blum_blum_shub.rb BOYGIR~1.RB" Another try: paths = SWin::CommonDialog::openFilename( nil, filetype_filter, OFN_EXPLORER| #<--let's try this one OFN_ALLOWMULTISELECT, 'Choose one or more files.') puts paths This looks better, but it doesn't work. When multiple files are selected I only get the directory back, none of the files. Help appreciated, Siep -- Posted via http://www.ruby-forum.com/.