本文整理汇总了C#中FileName.GetParentDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# FileName.GetParentDirectory方法的具体用法?C# FileName.GetParentDirectory怎么用?C# FileName.GetParentDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName.GetParentDirectory方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefaultAssemblySearcher
public DefaultAssemblySearcher(FileName mainAssemblyFileName)
{
if (mainAssemblyFileName == null)
throw new ArgumentNullException("mainAssemblyFileName");
this.mainAssemblyFileName = mainAssemblyFileName;
this.baseDirectory = mainAssemblyFileName.GetParentDirectory();
}
示例2: LoadTemplate
public TemplateBase LoadTemplate(FileName fileName)
{
var fileSystem = SD.FileSystem;
using (Stream stream = fileSystem.OpenRead(fileName)) {
return LoadTemplate(stream, new ReadOnlyChrootFileSystem(fileSystem, fileName.GetParentDirectory()));
}
}
示例3: OpenOutput
Stream OpenOutput(string gitExe, FileName fileName, string blobHash)
{
if (blobHash == null)
return null;
if (!File.Exists(fileName))
return null;
ProcessRunner runner = new ProcessRunner();
runner.WorkingDirectory = fileName.GetParentDirectory();
runner.RedirectStandardOutput = true;
runner.Start(gitExe, "cat-file", "blob", blobHash);
return runner.StandardOutput;
}
示例4: TestableInvokeUpdateWorkingDirectoryCmdlet
public TestableInvokeUpdateWorkingDirectoryCmdlet(
string solutionFileName,
FakePackageManagementProjectService projectService,
FakePackageManagementConsoleHost consoleHost,
FakeCmdletTerminatingError cmdletTerminatingError)
: base(projectService, consoleHost, cmdletTerminatingError)
{
this.FakeProjectService = projectService;
this.FakePackageManagementConsoleHost = consoleHost;
this.FakeCmdletTerminatingError = cmdletTerminatingError;
Solution = MockRepository.GenerateStub<ISolution>();
var fileName = new FileName(solutionFileName);
Solution.Stub(s => s.Directory).Return(fileName.GetParentDirectory());
Solution.Stub(s => s.FileName).Return(fileName);
projectService.OpenSolution = Solution;
}
示例5: CreateSharpDevelopSolution
SD.ISolution CreateSharpDevelopSolution(string fileName = @"d:\projects\MyProject\MyProject.sln")
{
var solution = MockRepository.GenerateStub<ISolution>();
var solutionFileName = new FileName(fileName);
solution.Stub(s => s.FileName).Return(solutionFileName);
solution.Stub(s => s.Directory).Return(solutionFileName.GetParentDirectory());
var sections = new SimpleModelCollection<SolutionSection>(new SolutionSection[0]);
solution.Stub(s => s.GlobalSections).Return(sections);
solution.Stub(s => s.MSBuildProjectCollection).Return(new ProjectCollection());
var projects = new SimpleModelCollection<IProject>();
solution.Stub(s =>s.Projects).Return(projects);
return solution;
}
示例6: GetBlobHashAsync
internal static async Task<string> GetBlobHashAsync(string gitExe, FileName fileName)
{
if (!File.Exists(fileName))
return null;
ProcessRunner runner = new ProcessRunner();
runner.WorkingDirectory = fileName.GetParentDirectory();
runner.RedirectStandardOutput = true;
runner.Start(gitExe, "ls-tree", "HEAD", fileName.GetFileName());
using (var reader = runner.OpenStandardOutputReader()) {
string firstLine = await reader.ReadLineAsync().ConfigureAwait(false);
if (firstLine != null) {
string[] parts = firstLine.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length >= 3) {
if (parts[2].Length == 40)
return parts[2];
}
}
}
return null;
}
示例7: SolutionWriter
public SolutionWriter(FileName fileName)
{
// we need to specify UTF8 because MSBuild needs the BOM
this.writer = new StreamWriter(fileName, false, Encoding.UTF8);
this.basePath = fileName.GetParentDirectory();
}
示例8: SetParentSolutionFileName
void SetParentSolutionFileName(string fileName)
{
var solutionFileName = new FileName(fileName);
msbuildProject.ParentSolution.Stub(s => s.FileName).Return(solutionFileName);
msbuildProject.ParentSolution.Stub(s => s.Directory).Return(solutionFileName.GetParentDirectory());
}
示例9: ObservedSave
public static FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, FileName fileName, string message, FileErrorPolicy policy = FileErrorPolicy.Inform)
{
System.Diagnostics.Debug.Assert(IsValidPath(fileName));
try {
Directory.CreateDirectory(fileName.GetParentDirectory());
saveFileAs(fileName);
RaiseFileSaved(new FileNameEventArgs(fileName));
return FileOperationResult.OK;
} catch (IOException e) {
return ObservedSaveHandleError(e, saveFileAs, fileName, message, policy);
} catch (UnauthorizedAccessException e) {
return ObservedSaveHandleError(e, saveFileAs, fileName, message, policy);
}
}