Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Iterating selected files from dialog box

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 26-07-2011
Member
 
Join Date: Jun 2011
Posts: 85
Iterating selected files from dialog box
  

I have a very genuine query with me, which I want to ask you experts to solve it for me. Basically I want to iterate process over selected files, what are they? The selected files are from dialog box. Please help me to iterate them. The below code I have used to count selected files:
Code:
Dim dlg as OpenDialog
  Dim f as FolderItem
  dlg=New OpenDialog

  dlg.Title="Select file(s)"
  dlg.MultiSelect = True

  f=dlg.ShowModal()
  
  MsgBox("dlg.Count = " + Str(dlg.Count))   /// shows the count of files selected

Reply With Quote
  #2  
Old 26-07-2011
Member
 
Join Date: May 2009
Posts: 518
Re: Iterating selected files from dialog box

Just have a look at COUNT and TRUE ITEM, if you get zero then itís confirmed that the file in the FolderItem is not a directory. If it contains no file than its not a directory. The below code will do it for you:
Code:
 if f.count>0 then 
       for i=0 to f.count-1
             f2=f.trueitem(i) 
       next i
    end if
Actually, you have to create a recursive procedure if you have sub directories in the directories.
Reply With Quote
  #3  
Old 26-07-2011
Member
 
Join Date: Apr 2009
Posts: 477
Re: Iterating selected files from dialog box

I drove my self into the same problem that is having sub directories under directories, which becomes tricky for us to handle. Also my set back was that RealBasic application pretends that it can select multiple lines in the fileopen dialog box but it doesnít. It only makes us think that and it only returns only one. The other application that allows one file to be selected will allow only one to be highlighted in the dialog box. So REALbasic is bug to me. The problem is with RB2008 and RB2009
Reply With Quote
  #4  
Old 26-07-2011
Member
 
Join Date: May 2009
Posts: 528
Re: Iterating selected files from dialog box

Language suggestion that tells us about property MultiSelect are:
  1. If True, the dialog supports multiple selections of files.
  2. The default is false.
  3. ShowModal still returns a FolderItem, but the FolderItem returned will be the first selection in the case of a MultiSelect OpenDialog.
  4. For a list of all selected FolderItems, it has added an element (zeroBasedIndex As Integer).
  5. With the Count as integer property it has FolderItem property along.
Reply With Quote
  #5  
Old 26-07-2011
Member
 
Join Date: Apr 2009
Posts: 562
Re: Iterating selected files from dialog box

The below code I have personally tested by myself and its working fine with me. But remember that the following code is tested only on windows. If you have different operating system then it might differ.
Code:
Dim dlg AS OpenDialog = New OpenDialog
  Dim ffile AS FolderItem
  
  dlg.MultiSelect = True
  ffile = dlg.ShowModal()
  
  for i As Integer = 0 to dlg.Count-1
    ffile = dlg.item(i)
    
    If ffile.exists Then
      'Do something with the file     
  End If
  next
Reply With Quote
  #6  
Old 26-07-2011
Member
 
Join Date: May 2009
Posts: 518
Re: Iterating selected files from dialog box

I have done many researches over the internet and came to conclusion that the REALbasic OpenDialog Folderitem multiselect option does not work properly. I wonder why it doesnít because its documentation reports that it is a feature of it. Actually I am a new to REALbasic but competent to Applescripter. Currently I have created an Applescript that will display identical file selection dialog box as REALbasic. But you can select more than one file at a time. The disadvantage would be that the names of the files that have to be returned to their regular budget proposal as a value of comma-delimited string, but this is easily converted into a string array of filenames, which can give RB code for that.
Reply With Quote
  #7  
Old 27-07-2011
Member
 
Join Date: May 2009
Posts: 602
Re: Iterating selected files from dialog box

Try the below code in your actual source code. It would allow the names of the files to return to there regular string. It is based on REALbasic, it will work properly.
Code:
Option Compare Database
Option Explicit

Private Sub cmdFileDialog_Click()

Dim fDialog As Office.FileDialog
Dim varFile As Variant

' Clear the list box contents.
Me.FileList.RowSource = ""

' Set up the File dialog box.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
' Allow the user to make multiple selections in the dialog box.
.AllowMultiSelect = True

' Set the title of the dialog box.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Iterating selected files from dialog box"
Thread Thread Starter Forum Replies Last Post
Microsoft Security Essentials: unable to scan selected files Ouka Networking & Security 4 28-08-2011 09:44 AM
Windows 7: Files are automatically get selected and Links are opened by hovering Mouse hostess Hardware Peripherals 6 09-03-2011 09:35 AM
Can nokia N79 music player play files only from a selected folder Jhooda Portable Devices 3 06-01-2011 07:13 PM
How to move files from temp dir to selected after completion in uTorrent? Kusumakar Technology & Internet 6 24-06-2010 10:32 PM
Files Remain Hidden Even though I selected show Hidden & Protected LabTechnician Vista Help 9 07-05-2007 01:32 PM


All times are GMT +5.5. The time now is 12:00 PM.