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


C# FileSystem.FileExists方法代码示例

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


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

示例1: CommandRunner

        public CommandRunner()
        {
            var path = AppDomain.CurrentDomain.BaseDirectory;

            var fileSystem = new FileSystem();

            bool isFound = fileSystem.FileExists(path, @"src\fubu\bin\debug", "fubu.exe");
            while (!isFound)
            {
                path = Path.Combine(path, "..");
                isFound = fileSystem.FileExists(path, @"src\fubu\bin\debug", "fubu.exe");
            }

            _solutionDirectory = Path.GetFullPath(path);
        }
开发者ID:hartez,项目名称:fubumvc,代码行数:15,代码来源:CommandRunner.cs

示例2: create_test_zip_to_a_nonexistent_path

        public void create_test_zip_to_a_nonexistent_path()
        {
            var fileSystem = new FileSystem();
            fileSystem.DeleteDirectory(".\\nonexist");

            fileSystem.FileExists(".\\nonexist\\silly.zip").ShouldBeFalse();

            fileSystem.WriteStringToFile(".\\bob.txt","hi");
            var service = new ZipFileService(fileSystem);
            service.CreateZipFile(".\\nonexist\\silly.zip", f=>
            {
                f.AddFile(".\\bob.txt","");
            });

            fileSystem.FileExists(".\\nonexist\\silly.zip").ShouldBeTrue();
        }
开发者ID:cprieto,项目名称:fubumvc,代码行数:16,代码来源:ZipFileServiceTester.cs

示例3: readDirectivesFromFile

        private void readDirectivesFromFile(FileSystem fileSystem)
        {
            Console.WriteLine("Reading directives from " + _file);

            if (!fileSystem.FileExists(_file))
            {
                throw new CommandFailureException("Designated serenity/jasmine file at {0} does not exist".ToFormat(_file));
            }

            fileSystem.ReadTextFile(_file, ReadText);
        }
开发者ID:GaryLCoxJr,项目名称:Serenity,代码行数:11,代码来源:ConfigFileLoader.cs

示例4: LoadForFolder

        public static Project LoadForFolder(string folder)
        {
            var system = new FileSystem();
            var file = folder.AppendPath(FILE);

            var project = system.FileExists(file) ? system.LoadFromFile<Project>(file) : new Project();

            project.ProjectPath = folder;

            return project;
        }
开发者ID:storyteller,项目名称:Storyteller,代码行数:11,代码来源:Project.cs

示例5: LocationOfRunner

        public static string LocationOfRunner(string file)
        {
            var folder = RippleExeLocation().ParentDirectory();
            var system = new FileSystem();

            if (system.FileExists(folder.AppendPath(file)))
            {
                return folder.AppendPath(file).ToFullPath();
            }

            return CodeDirectory().AppendPath("ripple", file);
        }
开发者ID:spascoe,项目名称:ripple,代码行数:12,代码来源:RippleFileSystem.cs

示例6: ReadFile

        public void ReadFile()
        {
            Console.WriteLine("Reading directives from " + _file);

            var fileSystem = new FileSystem();
            if (!fileSystem.FileExists(_file))
            {
                throw new CommandFailureException("Designated serenity/jasmine file at {0} does not exist".ToFormat(_file));
            }

            fileSystem.ReadTextFile(_file, ReadText);
        }
开发者ID:jemacom,项目名称:fubumvc,代码行数:12,代码来源:ConfigFileLoader.cs

示例7: writeSparkFile

        private void writeSparkFile(string directory, FileSystem fileSystem)
        {
            var sparkFile = directory.AppendPath(TopicName + ".spark");
            if (!fileSystem.FileExists(sparkFile))
            {
                Console.WriteLine("Writing " + sparkFile);
                var content = SparkTemplate.ToFormat(FullTopicClassName, Environment.NewLine);

                fileSystem.WriteStringToFile(sparkFile, content);
            }
        }
开发者ID:ventaur,项目名称:FubuWorld,代码行数:11,代码来源:TopicRequest.cs

示例8: WriteFiles

        public void WriteFiles()
        {
            var fileSystem = new FileSystem();

            var directory = NamespacedDirectory();
            writeSparkFile(directory, fileSystem);

            var classFile = directory.AppendPath(TopicName + ".cs");
            if (!fileSystem.FileExists(classFile))
            {
                Console.WriteLine("Writing " + classFile);
                var content = TopicClassTemplate.ToFormat(typeof (Topic).Namespace, FullNamespace, TopicName, Title);
                fileSystem.WriteStringToFile(classFile, content);
            }
        }
开发者ID:ventaur,项目名称:FubuWorld,代码行数:15,代码来源:TopicRequest.cs

示例9: findSolutionDir

        private static string findSolutionDir(string path, bool shouldThrow = true)
        {
            if (_stopAt(path)) return null;

            var files = new FileSystem();
            if (files.FileExists(path, SolutionFiles.ConfigFile))
            {
                return path;
            }

            var parent = new DirectoryInfo(path).Parent;
            if (parent == null)
            {
                if (shouldThrow)
                {
                    const string msg = "Not a ripple repository (or any of the parent directories)";
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(msg);
                    Console.ResetColor();

                    throw new RippleFatalError(msg);
                }

                return null;
            }

            return findSolutionDir(parent.FullName, shouldThrow);
        }
开发者ID:4lexm,项目名称:ripple,代码行数:28,代码来源:RippleFileSystem.cs

示例10: findSolutionDir

        private static string findSolutionDir(string path, bool shouldThrow = true)
        {
            if (_stopAt(path)) return null;

            var files = new FileSystem();
            if (files.FileExists(path, SolutionFiles.ConfigFile))
            {
                return path;
            }

            var parent = new DirectoryInfo(path).Parent;
            if (parent == null)
            {
                if (shouldThrow) RippleAssert.Fail("Not a ripple repository (or any of the parent directories)");
                return null;
            }

            return findSolutionDir(parent.FullName);
        }
开发者ID:bobpace,项目名称:ripple,代码行数:19,代码来源:RippleFileSystem.cs

示例11: FileSystem_FileExists_Finds_File

 public void FileSystem_FileExists_Finds_File()
 {
     IFileSystem fileSystem = new FileSystem();
     var result = fileSystem.FileExists(FS.FileExists.TargetPath);
     Assert.IsTrue(result);
 }
开发者ID:patrickhuber,项目名称:NoHtml,代码行数:6,代码来源:FileSystemTests.cs

示例12: findFubuFilename

        private string findFubuFilename()
        {
            var fileSystem = new FileSystem();
            var fileName = Path.Combine(_solutionDirectory, @"src\fubu\bin\debug\fubu.exe");

            if (fileSystem.FileExists(fileName))
            {
                return fileName;
            }

            fileName = Path.Combine(_solutionDirectory, @"src\fubu\bin\release\fubu.exe");
            if (fileSystem.FileExists(fileName))
            {
                return fileName;
            }

            return _solutionDirectory.AppendPath("fubu.cmd");
        }
开发者ID:plurby,项目名称:fubumvc,代码行数:18,代码来源:CommandRunner.cs

示例13: LoadForFolder

        public static Project LoadForFolder(string folder)
        {
            var system = new FileSystem();
            var file = folder.AppendPath(FILE);

            if (system.FileExists(file))
            {
                return system.LoadFromFile<Project>(file);
            }

            return new Project();
        }
开发者ID:jamesmanning,项目名称:Storyteller,代码行数:12,代码来源:Project.cs


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