本文整理汇总了C#中FileName.GetFileName方法的典型用法代码示例。如果您正苦于以下问题:C# FileName.GetFileName方法的具体用法?C# FileName.GetFileName怎么用?C# FileName.GetFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName.GetFileName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: FindXmlDocumentation
static string FindXmlDocumentation(FileName assemblyFileName, TargetRuntime runtime)
{
// First, look in the same directory as the assembly.
// This usually works for .NET reference assembies and 3rd party libraries
string xmlFileName = LookupLocalizedXmlDoc(assemblyFileName);
if (xmlFileName != null)
return xmlFileName;
// Otherwise, assume the assembly is part of .NET and try looking
// in the framework directory.
// (if the assembly is not part of .NET, we won't find anything there)
string name = assemblyFileName.GetFileName();
switch (runtime) {
case TargetRuntime.Net_1_0:
xmlFileName = LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v1.0.3705", name));
break;
case TargetRuntime.Net_1_1:
xmlFileName = LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v1.1.4322", name));
break;
case TargetRuntime.Net_2_0:
xmlFileName = LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, "v3.5", name))
?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v3.5\Profile\Client", name))
?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, "v3.0", name))
?? LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v2.0.50727", name));
break;
case TargetRuntime.Net_4_0:
default:
xmlFileName = LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.5.2", name))
?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.5.1", name))
?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.5", name))
?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.0", name))
?? LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v4.0.30319", name));
break;
}
return xmlFileName;
}