本文整理汇总了C#中IFileSystem.file_exists方法的典型用法代码示例。如果您正苦于以下问题:C# IFileSystem.file_exists方法的具体用法?C# IFileSystem.file_exists怎么用?C# IFileSystem.file_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileSystem
的用法示例。
在下文中一共展示了IFileSystem.file_exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VagrantService
public VagrantService(ICommandExecutor commandExecutor, IFileSystem fileSystem, IConfigurationSettings configuration)
{
_commandExecutor = commandExecutor;
_fileSystem = fileSystem;
_configuration = configuration;
var vagrantFound = false;
var customVagrantPath = _configuration.PathToVagrant;
if (!string.IsNullOrWhiteSpace(customVagrantPath))
{
if (!_fileSystem.file_exists(customVagrantPath))
{
this.Log().Warn("Unable to find vagrant at the path specified. Using default instance.");
}
else
{
this.Log().Warn("Using custom vagrant path at '{0}'.".format_with(customVagrantPath));
vagrantFound = true;
_vagrantExecutable = customVagrantPath;
}
}
if (!vagrantFound)
{
_vagrantExecutable = @"C:\HashiCorp\Vagrant\bin\vagrant.exe";
if (!_fileSystem.file_exists(_vagrantExecutable))
{
_vagrantExecutable = _fileSystem.get_executable_path("vagrant.exe");
}
}
//use_vagrant_directly();
}
示例2: extract_binary_file_from_assembly
/// <summary>
/// Extract binary file from an assembly to a location on disk
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <param name="assembly">The assembly.</param>
/// <param name="manifestLocation">The manifest location.</param>
/// <param name="filePath">The file path.</param>
/// <param name="overwriteExisting">
/// if set to <c>true</c> [overwrite existing].
/// </param>
public static void extract_binary_file_from_assembly(IFileSystem fileSystem, IAssembly assembly, string manifestLocation, string filePath, bool overwriteExisting = false)
{
if (overwriteExisting || !fileSystem.file_exists(filePath))
{
fileSystem.create_directory_if_not_exists(fileSystem.get_directory_name(filePath));
fileSystem.write_file(filePath, () => assembly.get_manifest_stream(manifestLocation));
}
}
示例3: get_powershell_location
public static string get_powershell_location(IFileSystem fileSystem)
{
foreach (var powershellLocation in _powershellLocations)
{
if (fileSystem.file_exists(powershellLocation)) return powershellLocation;
}
var message = "Unable to find suitable location for PowerShell. Searched the following locations: '{0}'".format_with(string.Join("; ", _powershellLocations));
"PowerShellExecutor".Log().Error(message);
throw new FileNotFoundException(message);
}
示例4: get_powershell_location
public static string get_powershell_location(IFileSystem fileSystem)
{
foreach (var powershellLocation in _powershellLocations)
{
if (fileSystem.file_exists(powershellLocation))
{
return powershellLocation;
}
}
throw new FileNotFoundException("Unable to find suitable location for PowerShell. Searched the following locations: '{0}'".format_with(string.Join("; ", _powershellLocations)));
}
示例5: validate
public static void validate(IFileSystem fileSystem)
{
string licenseFile = ApplicationParameters.LicenseFileLocation;
if (fileSystem.file_exists(licenseFile))
{
new LicenseValidator(PUBLIC_KEY, licenseFile).AssertValidLicense();
}
else
{
//free version
}
}
示例6: extract_text_file_from_assembly
/// <summary>
/// Extract text file from assembly to location on disk.
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <param name="assembly">The assembly.</param>
/// <param name="manifestLocation">The manifest location.</param>
/// <param name="filePath">The file path.</param>
/// <param name="overwriteExisting">
/// if set to <c>true</c> [overwrite existing].
/// </param>
/// <exception cref="System.IO.FileNotFoundException"></exception>
public static void extract_text_file_from_assembly(IFileSystem fileSystem, IAssembly assembly, string manifestLocation, string filePath, bool overwriteExisting = false)
{
if (overwriteExisting || !fileSystem.file_exists(filePath))
{
fileSystem.create_directory_if_not_exists(fileSystem.get_directory_name(filePath));
var fileText = assembly.get_manifest_string(manifestLocation);
if (string.IsNullOrWhiteSpace(fileText))
{
string errorMessage = "Could not find a file in the manifest resource stream of '{0}' at '{1}'.".format_with(assembly.FullName, manifestLocation);
"chocolatey".Log().Error(() => errorMessage);
throw new FileNotFoundException(errorMessage);
}
fileSystem.write_file(filePath, fileText, Encoding.UTF8);
}
}