當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。