コード例 #1
0
        public static string OpenFileOfType(
            string dlgTitle, FileType fileType, string dirRelativeToBase, string absoluteDir)
        {
            try
            {
                var dlg = new OpenFileDialog();
                if (dlgTitle != "")
                {
                    dlg.Title = dlgTitle;
                }

                dlg.Multiselect = false;

                if (dirRelativeToBase != "")
                {
                    dlg.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory + dirRelativeToBase; // "Settings";
                }
                else if (absoluteDir != "")
                {
                    dlg.InitialDirectory = absoluteDir;
                }

                dlg.Filter = Utilities.OpenFileFunctions.UsedFileTypesFilterNames[fileType] + "|*."
                             + fileType.ToString();
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return "";
                }
                else
                {
                    return dlg.FileName;
                }
            }
            catch (Exception OpenFileOfTypeExp)
            {
                MessageBox.Show("Error in OpenFileOfType(...): " + OpenFileOfTypeExp);
                return null;
            }
        }
コード例 #2
0
 /// <summary>Initializes an instance of the FileAssociation class.</summary>
 public FileAssociation()
 {
     FileInfo = new FileType();
     FileInfo.Commands.Captions = new ArrayList();
     FileInfo.Commands.Commands = new ArrayList();
 }
コード例 #3
0
 public static string OpenFileOfType(string dlgTitle, FileType fileType, string dirRelativeToBase)
 {
     return OpenFileOfType(dlgTitle, fileType, dirRelativeToBase, "");
 }