def get_files(dirname=None, pattern='*.*', recursive=True):
    """
    Get all file names within a given directory those names match a
    given pattern.

    Parameters
    ----------
    dirname : str | None
        Directory containing the datafiles.
        If None is given, open a dialog box.
    pattern : str
        Return only files whose names match the specified pattern.
    recursive : bool
        True : Search recursively within all sub-directories.
        False : Search only in given directory.

    Returns
    -------
    matches: list
       List of file names (including full path).
    """
    # get dirname from user if not given
    if dirname is None:
        from FlowCytometryTools.gui import dialogs
        dirname = dialogs.select_directory_dialog('Select a directory')

    # find all files in dirname that match pattern
    if recursive:  # search subdirs
        matches = []
        for root, dirnames, filenames in os.walk(dirname):
            for filename in fnmatch.filter(filenames, pattern):
                matches.append(os.path.join(root, filename))
    else:
        matches = glob.glob(os.path.join(dirname, pattern))
    return matches