OFD_Class

    1| using System;
    2| using System.Collections.Generic;
    3| using System.Text;
    4| 
    5| //add using statements
    6| using System.Windows.Forms;
    7| using System.Collections;
    8| 
    9| namespace Open_File_Dialog
  10| {
  11|     public class OFD_Class
  12|     {
  13|         public static ArrayList OFD_Get_Files(string sInit_Dir, bool bMultiSelections, string sTitle)
  14|         {
  15|             //Declare an ArrayList object
  16|             ArrayList oArrayList = new ArrayList(1);
  17| 
  18|             OpenFileDialog oFD = new OpenFileDialog();
  19| 
  20|             //Set the OpenFielDialog Object's parameters
  21|             oFD.InitialDirectory = sInit_Dir;
  22|             oFD.Multiselect = bMultiSelections;
  23|             oFD.Title = sTitle;
  24| 
  25|             DialogResult result = oFD.ShowDialog();
  26| 
  27|             //Retrieve the files from the result
  28|             if (result != DialogResult.Cancel)
  29|             {
  30|                 foreach (string sFile in oFD.FileNames)
  31|                 {
  32|                     oArrayList.Add(sFile);
  33|                 }
  34|             }
  35| 
  36|             return oArrayList;
  37|         }
  38| 
  39|         //Get the root drives for this computer
  40|         public static ArrayList oFD_Get_Drive_Roots()
  41|         {
  42|             ArrayList oDriveRootList = new ArrayList(1);
  43|             string[] sDriveArray;
  44| 
  45|             //Statement to retrieve the available drive letters
  46|             sDriveArray = System.IO.Directory.GetLogicalDrives();
  47| 
  48|             // get the drive and root
  49|             foreach (string sRoot in sDriveArray)
  50|             {
  51|                 oDriveRootList.Add(sRoot);
  52|             }
  53| 
  54|             return oDriveRootList;
  55|         }
  56| 
  57|     }//end of class
  58| }