GetUnusedPath() public static method

public static GetUnusedPath ( string name ) : string
name string
return string
コード例 #1
0
        private static CompilerResults CompileVBScripts(bool debug)
        {
            int num1;
            int num2;

            object[]       objArray1;
            VBCodeProvider provider1 = new VBCodeProvider();
            ICodeCompiler  compiler1 = provider1.CreateCompiler();

            Console.Write("Scripts: Compiling VB.net scripts...");
            string[] textArray1 = ScriptCompiler.GetScripts("*.vb");
            if (textArray1.Length == 0)
            {
                Console.WriteLine("no files found.");
                return(null);
            }
            string          text1    = ScriptCompiler.GetUnusedPath("Scripts.VB");
            CompilerResults results1 = compiler1.CompileAssemblyFromFileBatch(new CompilerParameters(ScriptCompiler.GetReferenceAssemblies(), text1, true), textArray1);

            ScriptCompiler.m_AdditionalReferences.Add(text1);
            if (results1.Errors.Count > 0)
            {
                num1 = 0;
                num2 = 0;
                foreach (CompilerError error1 in results1.Errors)
                {
                    if (error1.IsWarning)
                    {
                        ++num2;
                        continue;
                    }
                    ++num1;
                }
                if (num1 > 0)
                {
                    Console.WriteLine("failed ({0} errors, {1} warnings)", num1, num2);
                }
                else
                {
                    Console.WriteLine("done ({0} errors, {1} warnings)", num1, num2);
                }
                foreach (CompilerError error2 in results1.Errors)
                {
                    objArray1    = new object[6];
                    objArray1[0] = (error2.IsWarning ? "Warning" : "Error");
                    objArray1[1] = error2.FileName;
                    objArray1[2] = error2.ErrorNumber;
                    objArray1[3] = error2.Line;
                    objArray1[4] = error2.Column;
                    objArray1[5] = error2.ErrorText;
                    Console.WriteLine(" - {0}: {1}: {2}: (line {3}, column {4}) {5}", objArray1);
                }
                return(results1);
            }
            Console.WriteLine("done (0 errors, 0 warnings)");
            return(results1);
        }