C# Directory.GetCurrentDirectory的代码示例

通过代码示例来学习C# Directory.GetCurrentDirectory方法

通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。


Directory.GetCurrentDirectory是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的Directory.GetCurrentDirectory() 已经帮大家高亮显示了,大家可以重点学习Directory.GetCurrentDirectory() 方法的写法,从而快速掌握该方法的应用。

Directory.GetCurrentDirectory的代码示例1 - Main()

    using System.IO;
        static void Main(string[] args)
        {
            string basepath = Directory.GetCurrentDirectory();
            Directory.CreateDirectory(Path.Combine(basepath, "outline"));
            Directory.CreateDirectory(Path.Combine(basepath, "frame"));

            Directory.CreateDirectory(Path.Combine(basepath, "imagetest"));

            GerberFrameWriter.FrameSettings FS = new GerberFrameWriter.FrameSettings();
            PolyLine PL = new PolyLine();
            FS.FrameTitle = "Test Frame";
            FS.RenderSample = false;
            FS.margin = 3;

            PL.MakeRoundedRect(new PointD(-50, -50), new PointD(50, 50), 7);
            //FS.offset = new PointD(200, 200);
            FS.RenderSample = false;

            GerberArtWriter GAW = new GerberArtWriter();
            GAW.AddPolyLine(PL);
            
            GAW.Write("outline/outtestinside.gko");

            // Bitmap FrontPrint = (Bitmap)Bitmap.FromFile("BigJigImage.png");
            // Bounds FrontBound = new Bounds() { BottomRight = new PointD(220, 230), TopLeft = new PointD(-220, -230) , Valid = true};

            // PCBWriterSet s = new PCBWriterSet();
            // s.TopSilk.WriteImageToBounds(FrontPrint, FrontBound, new Bounds() { TopLeft = new PointD(-10, -10), BottomRight = new PointD(10, 10),Valid = true });
            // s.Write("imagetest", "test!");

            FS.RenderDirectionArrow = true;
            FS.DirectionArrowSide = GerberLibrary.Core.BoardSide.Bottom;
            FS.DefaultFiducials = true;
            FS.FiducialSide = BoardSide.Both;
            FS.HorizontalTabs = true;
            FS.VerticalTabs = true;
            FS.InsideEdgeMode = GerberFrameWriter.FrameSettings.InsideMode.FormFitting;
            FS.PositionAround(PL);
            BOM OutFiducials = new BOM();
            GerberFrameWriter.WriteSideEdgeFrame(PL, FS, Path.Combine(basepath, "frame/outtest"), OutFiducials);
            FS.RenderSample = true;
            GerberFrameWriter.MergeFrameIntoGerberSet(Path.Combine(basepath, "frame"), Path.Combine(basepath, "outline"), Path.Combine(basepath, "mergedoutput"),FS, new FrameCreatorTest(),"testframe");

            //           GerberFrameWriter.MergeFrameIntoGerberSet(Path.Combine(basepath, "SliceFrameOutline6"), Path.Combine(basepath, "Slice6"), Path.Combine(basepath, "slice6inframe"), FS, new FrameCreatorTest(),"slice6framed" );
            // PNL.SaveOutlineTo("panelized.gko", "panelcombinedgko.gko");
            //Console.ReadKey();
        }
    

开发者ID:ThisIsNotRocketScience,项目名称:GerberTools,代码行数:48,代码来源:FrameCreatorTest.cs

在Main()方法中,Directory的代码示例类中的GetCurrentDirectory的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

Directory.GetCurrentDirectory的代码示例2 - CurrentDirectoryToUse()

    using System.IO;

        /// 
        /// Get the current directory that the compiler should run in.
        /// 
        private string CurrentDirectoryToUse()
        {
            // ToolTask has a method for this. But it may return null. Use the process directory
            // if ToolTask didn't override. MSBuild uses the process directory.
            var workingDirectory = GetWorkingDirectory();
            if (string.IsNullOrEmpty(workingDirectory))
            {
                workingDirectory = Directory.GetCurrentDirectory();
            }
            return workingDirectory;
        }
    

开发者ID:aspnet,项目名称:Razor,代码行数:16,代码来源:DotnetToolTask.cs

在CurrentDirectoryToUse()方法中,Directory的代码示例类中的GetCurrentDirectory的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

Directory.GetCurrentDirectory的代码示例3 - Main()

    using System.IO;
        public static int Main(string[] args)
        {
            if (args == null || args.Length < 1)
            {
                Console.WriteLine("Invalid argument(s).");
                Console.WriteLine(@"Usage:   
    dotnet razorpagegenerator  [path]
Examples: 
    dotnet razorpagegenerator Microsoft.AspNetCore.Diagnostics.RazorViews
        - processes all views in ""Views"" subfolders of the current directory
    dotnet razorpagegenerator Microsoft.AspNetCore.Diagnostics.RazorViews c:\project
        - processes all views in ""Views"" subfolders of c:\project directory
");

                return 1;
            }

            var rootNamespace = args[0];
            var targetProjectDirectory = args.Length > 1 ? args[1] : Directory.GetCurrentDirectory();
            var projectEngine = CreateProjectEngine(rootNamespace, targetProjectDirectory);
            var results = MainCore(projectEngine, targetProjectDirectory);

            foreach (var result in results)
            {
                File.WriteAllText(result.FilePath, result.GeneratedCode);
            }

            Console.WriteLine();
            Console.WriteLine($"{results.Count} files successfully generated.");
            Console.WriteLine();
            return 0;
        }
    

开发者ID:aspnet,项目名称:Razor,代码行数:33,代码来源:Program.cs

在Main()方法中,Directory的代码示例类中的GetCurrentDirectory的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

Directory.GetCurrentDirectory的代码示例4 - TestLongPaths()

    using System.IO;

        // Unzip src/SauronEyeTests/testfiles.zip first
        [TestMethod]
        public void TestLongPaths() {
            var LongDirectories = new List {
                Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + @"\testfiles\ininfafasf ienflaflieflanfeifnalnfae\ininfafasf ienflaflieflanfeifnalnfae\ininfafasf ienflaflieflanfeifnalnfae\ininfafasf ienflaflieflanfeifnalnfae\ienflaflieflanfeifnalnfae\dfiwnfwnfwnfownefinewnf.txt",
            };
            var Regex = new SauronEye.RegexSearch(new List { "pass" } );
            var Keywords = new List { "pass" };
            var ContentSearcher = new SauronEye.ContentsSearcher(LongDirectories, Keywords, Regex, 1024);
            ContentSearcher.Search();

            var currentConsoleOut = Console.Out;

            var outputPath = @"ininfafasf ienflaflieflanfeifnalnfae\ininfafasf ienflaflieflanfeifnalnfae\ininfafasf ienflaflieflanfeifnalnfae\ininfafasf ienflaflieflanfeifnalnfae\ienflaflieflanfeifnalnfae\dfiwnfwnfwnfownefinewnf.txt";
            var outputMatch = @"this is pass";
            using (var consoleOutput = new ConsoleOutput())
            {
                ContentSearcher.Search();
                Assert.IsTrue(consoleOutput.GetOuput().Contains(outputPath));
                Assert.IsTrue(consoleOutput.GetOuput().Contains(outputMatch));
            }

            Assert.AreEqual(currentConsoleOut, Console.Out);

        }
    

开发者ID:vivami,项目名称:SauronEye,代码行数:27,代码来源:UnitTests.cs

在TestLongPaths()方法中,Directory的代码示例类中的GetCurrentDirectory的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

Directory.GetCurrentDirectory的代码示例5 - Run()

    using System.IO;

		public Startup Run()
		{
			var outputDirectoryPath = Path.Combine(Directory.GetCurrentDirectory(), "Output");
			if (Directory.Exists(outputDirectoryPath))
			{
				Directory.Delete(outputDirectoryPath, true);
			}

			Directory.CreateDirectory(outputDirectoryPath);

			var xmlDocs = XElement.Load("CsvHelper.xml");

			var assemblyInfo = new AssemblyInfo(typeof(CsvHelperException).Assembly, xmlDocs);

			GenerateMarkdownFiles(outputDirectoryPath, assemblyInfo);
			GenerateToc(outputDirectoryPath, assemblyInfo);

			return this;
		}
    

开发者ID:JoshClose,项目名称:CsvHelper,代码行数:21,代码来源:Startup.cs

在Run()方法中,Directory的代码示例类中的GetCurrentDirectory的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

Directory.GetCurrentDirectory的代码示例6 - FindAllSources()

    using System.IO;

        private static void FindAllSources(string[] sourcesArguments, string solutionPath, Sharpmake.Arguments sharpmakeArguments, string startArguments)
        {
            MainSources = sourcesArguments;
            if (!string.IsNullOrEmpty(solutionPath))
            {
                RootPath = solutionPath;
                if (!Path.IsPathRooted(RootPath))
                {
                    RootPath = Path.Combine(Directory.GetCurrentDirectory(), RootPath);
                }
                Directory.CreateDirectory(RootPath);
            }
            else
            {
                RootPath = Path.GetDirectoryName(sourcesArguments[0]);
            }

            Assembler assembler = new Assembler(sharpmakeArguments.Builder.Defines);
            assembler.AttributeParsers.Add(new DebugProjectNameAttributeParser());
            IAssemblyInfo assemblyInfo = assembler.LoadUncompiledAssemblyInfo(Builder.Instance.CreateContext(BuilderCompileErrorBehavior.ReturnNullAssembly), MainSources);

            GenerateDebugProject(assemblyInfo, true, startArguments, new Dictionary(), sharpmakeArguments.Builder.Defines.ToArray());
        }
    

开发者ID:ubisoft,项目名称:Sharpmake,代码行数:25,代码来源:DebugProjectGenerator.cs

在FindAllSources()方法中,Directory的代码示例类中的GetCurrentDirectory的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

Directory.GetCurrentDirectory的代码示例7 - AddFakeFiles()

    using System.IO;

        private void AddFakeFiles(IEnumerable sharpmakeProjects)
        {
            Util.FakePathPrefix = Directory.GetCurrentDirectory();

            var fakeFileExtensions = new List();
            switch (_initType)
            {
                case InitType.Cpp:
                    fakeFileExtensions.Add("_source.cpp");
                    fakeFileExtensions.Add("_header.h");
                    break;
                case InitType.CSharp:
                    fakeFileExtensions.Add("_source.cs");
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            foreach (var sharpmakeProject in sharpmakeProjects)
            {
                foreach (string fakeFileExtension in fakeFileExtensions)
                    Util.AddNewFakeFile(Util.PathMakeStandard(Path.Combine(sharpmakeProject.Name, sharpmakeProject.Name + fakeFileExtension)), 0);
            }
        }
    

开发者ID:ubisoft,项目名称:Sharpmake,代码行数:26,代码来源:TestProjectBuilder.cs

在AddFakeFiles()方法中,Directory的代码示例类中的GetCurrentDirectory的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

Directory.GetCurrentDirectory的代码示例8 - TestUncompilableNotInCompileSources()

    using System.IO;

        [Test]
        public void TestUncompilableNotInCompileSources()
        {
            string xCodeTargetName = "test";
            var srcRoot = Directory.GetCurrentDirectory();
            List sourceFiles = new List { Path.Combine(srcRoot, "test.sc") };
            Project project = new Project();
            Project.Configuration configuration = new Project.Configuration();

            configuration.ProjectFullFileNameWithExtension = "./test/test.xcodeproj";

            var xcodePrj = new XCodeProj();

            project.SourceRootPath = srcRoot;
            xcodePrj._sourcesBuildPhases = new Dictionary();
            var projectSourcesBuildPhase = new ProjectSourcesBuildPhase(xCodeTargetName, 2147483647);
            xcodePrj._projectItems.Add(projectSourcesBuildPhase);
            xcodePrj._sourcesBuildPhases.Add(xCodeTargetName, projectSourcesBuildPhase);
            xcodePrj.SetRootGroup(project, configuration);
            xcodePrj.PrepareSourceFiles(xCodeTargetName, sourceFiles, project, configuration, false);
            var compileSources = xcodePrj._projectItems.Where(item => item is ProjectBuildFile);

            Assert.IsTrue(compileSources.Count() == 0);
        }
    

开发者ID:ubisoft,项目名称:Sharpmake,代码行数:26,代码来源:TestXcodeProjectGenerator.cs

在TestUncompilableNotInCompileSources()方法中,Directory的代码示例类中的GetCurrentDirectory的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞

本文中的Directory.GetCurrentDirectory方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。