当前位置: 首页>>代码示例>>C#>>正文


C# FileSystem.DirectoryExists方法代码示例

本文整理汇总了C#中FileSystem.DirectoryExists方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystem.DirectoryExists方法的具体用法?C# FileSystem.DirectoryExists怎么用?C# FileSystem.DirectoryExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileSystem的用法示例。


在下文中一共展示了FileSystem.DirectoryExists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RefreshAssemblies

        private static void RefreshAssemblies(ILog log)
        {
            var fileSystem = new FileSystem();

            var packagesFolder = Path.Combine(fileSystem.CurrentDirectory, "packages");

            if(fileSystem.DirectoryExists(packagesFolder))
            {
                // Delete any blacklisted packages to avoid various issues with PackageAssemblyResolver
                // https://github.com/scriptcs/scriptcs/issues/511
                foreach (var packagePath in
                    _blacklistedPackages.SelectMany(packageName => Directory.GetDirectories(packagesFolder)
                                .Where(d => new DirectoryInfo(d).Name.StartsWith(packageName, StringComparison.InvariantCultureIgnoreCase)),
                                (packageName, packagePath) => new {packageName, packagePath})
                        .Where(t => fileSystem.DirectoryExists(t.packagePath))
                        .Select(t => @t.packagePath))
                {
                    fileSystem.DeleteDirectory(packagePath);
                }
            }

            var par = new PackageAssemblyResolver(fileSystem, new PackageContainer(fileSystem, log), log);

            _assemblies = par.GetAssemblyNames(fileSystem.CurrentDirectory).ToList();

            // Add the assemblies in the current directory
            _assemblies.AddRange(Directory.GetFiles(fileSystem.CurrentDirectory, "*.dll")
                .Where(a => new AssemblyUtility().IsManagedAssembly(a)));
        }
开发者ID:kiwidev,项目名称:mmbot,代码行数:29,代码来源:NuGetPackageAssemblyResolver.cs

示例2: DirectoryExists

 public void DirectoryExists()
 {
     var curDirectory = Directory.GetCurrentDirectory();
     var existingFile = Path.Combine(curDirectory, "../../");
     var fileSystem = new FileSystem();
     Assert.IsTrue(fileSystem.DirectoryExists(existingFile));
     var notExistingFile = Path.Combine(curDirectory, "../../" + notExisting + "/");
     Assert.IsFalse(fileSystem.DirectoryExists(notExistingFile));
 }
开发者ID:stormleoxia,项目名称:lx,代码行数:9,代码来源:FileSystemTest.cs

示例3: Main

        public static int Main(string[] args)
        {
            var fileSystem = new FileSystem();

            string srcDirectory = AppDomain.CurrentDomain.BaseDirectory.ParentDirectory().ParentDirectory().ParentDirectory().ParentDirectory();
            string buildDirectory = args.Any()
                                        ? args.Single()
                                        : srcDirectory.ParentDirectory().ParentDirectory().AppendPath("buildsupport");

            Console.WriteLine("Trying to copy to " + buildDirectory);
            if (!fileSystem.DirectoryExists(buildDirectory))
            {
                throw new ApplicationException("Could not find the buildsupport directory");
            }

            var targetDirectory = buildDirectory.AppendPath("FubuDocs");

            fileSystem.CreateDirectory(targetDirectory);
            fileSystem.CleanDirectory(targetDirectory);

            var fromDirectory = srcDirectory.AppendPath("FubuDocsRunner").AppendPath("bin").AppendPath("debug");
            var files = FileSet.Deep("*.dll;*.pdb;*.exe");
            fileSystem.FindFiles(fromDirectory, files).Each(file => {
                Console.WriteLine("Copying {0} to {1}", file, targetDirectory);
                fileSystem.Copy(file, targetDirectory, CopyBehavior.overwrite);
            });

            return 0;
        }
开发者ID:mtscout6,项目名称:FubuWorld,代码行数:29,代码来源:Program.cs

示例4: BatchTest

        public async Task BatchTest()
        {
            FileSystem fs = new FileSystem();
            string path = @"C:\PathToSpecs"; //path to specs
            Assert.True(fs.DirectoryExists(path), $"{path} does not exist");

            // get all of the json and yaml files from filesystem
            string[] files = fs.GetFilesByExtension(path, SearchOption.AllDirectories, "json", "yaml");
            Assert.True(files.Count() > 0, $"{path} does not contain any json or yaml files");

            foreach (string file in files)
            {
                // Comment this block out if not needed
                if (!fs.ReadFileAsText(file).Contains(@"""swagger"": ""2.0"""))
                {
                    //skip files that are not swagger files.
                    continue;
                }

                using (var memoryFileSystem = GenerateCodeForTestFromSpec(file))
                {
                    // Expected Files
                    Assert.True(memoryFileSystem.GetFiles(@"GeneratedCode\", "*.cs", SearchOption.TopDirectoryOnly).GetUpperBound(0) > 0);
                    Assert.True(memoryFileSystem.GetFiles(@"GeneratedCode\Models\", "*.cs", SearchOption.TopDirectoryOnly).GetUpperBound(0) > 0);

                    var result = await Compile(memoryFileSystem);

                    // filter the warnings
                    var warnings = result.Messages.Where(
                        each => each.Severity == DiagnosticSeverity.Warning
                                && !SuppressWarnings.Contains(each.Id)).ToArray();

                    // use this to dump the files to disk for examination
                    // memoryFileSystem.SaveFilesToTemp(file.Name);

                    // filter the errors
                    var errors = result.Messages.Where(each => each.Severity == DiagnosticSeverity.Error).ToArray();

                    Write(warnings, memoryFileSystem);
                    Write(errors, memoryFileSystem);

                    // use this to write out all the messages, even hidden ones.
                    // Write(result.Messages, memoryFileSystem);

                    // Don't proceed unless we have zero Warnings.
                    Assert.Empty(warnings);

                    // Don't proceed unless we have zero Errors.
                    Assert.Empty(errors);

                    // Should also succeed.
                    Assert.True(result.Succeeded);
                }
            }
        }
开发者ID:jhancock93,项目名称:autorest,代码行数:55,代码来源:BatchTestSpecs.cs

示例5: FindSettings

        public ApplicationSettings FindSettings()
        {
            if (Location.IsEmpty())
            {
                return new ApplicationSettings{
                    PhysicalPath = ".".ToFullPath(),
                    ParentFolder = ".".ToFullPath()
                };
            }

            var system = new FileSystem();
            if (system.FileExists(Location) && system.IsFile(Location))
            {
                Console.WriteLine("Reading application settings from " + Location);
                return ApplicationSettings.Read(Location);
            }

            if (system.DirectoryExists(Location))
            {
                return findFromDirectory(system);
            }

            return findByName(system);
        }
开发者ID:wbinford,项目名称:fubu,代码行数:24,代码来源:AppInput.cs


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