本文整理汇总了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);
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}
示例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();
}