Results 1 to 7 of 7

Thread: Iterating selected files from dialog box

  1. #1
    Join Date
    Jun 2011

    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:
    Dim dlg as OpenDialog
      Dim f as FolderItem
      dlg=New OpenDialog
      dlg.Title="Select file(s)"
      dlg.MultiSelect = True
      MsgBox("dlg.Count = " + Str(dlg.Count))   /// shows the count of files selected

  2. #2
    Join Date
    May 2009

    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:
     if f.count>0 then 
           for i=0 to f.count-1
           next i
        end if
    Actually, you have to create a recursive procedure if you have sub directories in the directories.

  3. #3
    Join Date
    Apr 2009

    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

  4. #4
    Join Date
    May 2009

    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.

  5. #5
    Join Date
    Apr 2009

    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.
    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

  6. #6
    Join Date
    May 2009

    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.

  7. #7
    Join Date
    May 2009

    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.
    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.

Similar Threads

  1. Microsoft Security Essentials: unable to scan selected files
    By Ouka in forum Networking & Security
    Replies: 4
    Last Post: 28-08-2011, 09:44 AM
  2. Replies: 6
    Last Post: 09-03-2011, 09:35 AM
  3. Replies: 3
    Last Post: 06-01-2011, 07:13 PM
  4. Replies: 6
    Last Post: 24-06-2010, 10:32 PM
  5. Replies: 9
    Last Post: 07-05-2007, 01:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts