Пример #1
0
        /// <summary>
        /// 执行宏新建指令
        /// </summary>
        /// <exception cref="UnauthorizedAccessException"></exception>
        private void ExecuteMacroNew()
        {
            List <string> macroInstructionParameters = GetMacroInstructionParametersList();

            // Handle [in] sytex
            string inWhere = AFile.ATEMP_PATH;

            if (macroInstructionParameters.Count >= 3 && "in" == macroInstructionParameters[macroInstructionParameters.Count - 2])
            {
                string lastParam = macroInstructionParameters[macroInstructionParameters.Count - 1];
                if (AFile.Exists(lastParam))
                {
                    // If the item is already a directory
                    string itemPath = AFile.GetFullPath(lastParam);
                    if (Directory.Exists(itemPath))
                    {
                        inWhere = itemPath;
                    }
                    // If the item is exist
                    else if (File.Exists(itemPath))
                    {
                        inWhere = Path.GetDirectoryName(itemPath);
                    }
                    else
                    {
                        throw new NotImplementedException("The startup item [" + lastParam + "] is not found in disk.");
                    }
                }
                else if (Directory.Exists(lastParam))
                {
                    inWhere = lastParam;
                }
                else
                {
                    throw new NotImplementedException("The directory [" + lastParam + "] is not exist.");
                }
                macroInstructionParameters.RemoveRange(macroInstructionParameters.Count - 2, 2);
            }
            // Remove the last '\'
            if (inWhere.Last() == '\\')
            {
                inWhere = inWhere.Substring(0, inWhere.Length - 1);
            }

            foreach (string newFileName in macroInstructionParameters)
            {
                string fileName = AConstQuote.ConstQuoteParse(newFileName);
                string filePath = inWhere + @"\" + fileName;
                using (StreamWriter streamWriter = new StreamWriter(filePath, false)) { }
                AFile.StartupProcess(filePath);
                //AFile.LaunchTempFile(fileName);
            }
        }
Пример #2
0
 public void GetFullPathTest(string startupName, string expected)
 {
     Assert.AreEqual(expected, AFile.GetFullPath(startupName));
 }