Esempio n. 1
0
        /// <summary>
        /// 获取命令
        /// </summary>
        /// <param name="originalShortName">简称</param>
        /// <returns></returns>
        private string GetCommand(string originalShortName)
        {
            string command = GetCommandFormSetting(originalShortName);

            //对应的命令不存在
            if (string.IsNullOrEmpty(command))
            {
                return(CommandNotInConfig(originalShortName));
            }

            //是目录或文件路径
            bool isDirectoryOrFilePath = FileAndDirectoryHelper.IsDirectoryOrFilePath(command);

            if (isDirectoryOrFilePath && FileAndDirectoryHelper.PathIsNotExists(command))
            {
                MessageBoxHelper.ShowErrorMessageBox($@"对应路径不存在:{command}");
                return(string.Empty);
            }

            if (isDirectoryOrFilePath || IsWellFormedUriString(command))
            {
                return(ConvertCommandWithQuote(command));
            }

            return(SimpleCommand(command));
        }
Esempio n. 2
0
        /// <summary>
        /// 获取命令
        /// </summary>
        /// <param name="originalShortName">简称</param>
        /// <returns></returns>
        private string GetCommand(string originalShortName)
        {
            string command = GetCommandFormSetting(originalShortName);

            //简称对应的命令不存在
            if (string.IsNullOrEmpty(command))
            {
                //简称是URL网址或文件路径,则直接打开
                if (IsWellFormedUriString(originalShortName) || FileAndDirectoryHelper.PathIsExists(originalShortName))
                {
                    return(ConvertCommandWithQuote(originalShortName));
                }

                //搜索该简称
                return(GetSearchCommand(originalShortName));
            }

            //满足URI格式
            if (IsWellFormedUriString(command))
            {
                return(ConvertCommandWithQuote(command));
            }

            //是目录或文件路径
            if (FileAndDirectoryHelper.IsDirectoryOrFilePath(command))
            {
                //路径不存在
                if (FileAndDirectoryHelper.PathIsNotExists(command))
                {
                    MessageBoxHelper.ShowErrorMessageBox(string.Format(@"对应路径不存在:{0}", command));
                    return(string.Empty);
                }

                return(ConvertCommandWithQuote(command));
            }

            return(string.Format("start \"\" {0}", command));
        }