public IsAbsolutePath ( string path ) : bool | ||
path | string | |
Результат | bool |
public virtual bool IsAbsolutePath(string path) {
#if !SILVERLIGHT
// GetPathRoot returns either :
// "" -> relative to the current dir
// "\" -> relative to the drive of the current dir
// "X:" -> relative to the current dir, possibly on a different drive
// "X:\" -> absolute
if (IsSingleRootFileSystem) {
return Path.IsPathRooted(path);
}
var root = Path.GetPathRoot(path);
return root.EndsWith(@":\") || root.EndsWith(@":/");
#else
throw new NotImplementedException();
#endif
}
private static IEnumerable<string>/*!*/ GetAbsolutePaths(PlatformAdaptationLayer/*!*/ pal, string/*!*/ path) { if (pal.IsAbsolutePath(path)) { yield return path; } else { yield return pal.GetFullPath(path); string var = pal.GetEnvironmentVariable("PATH"); if (!String.IsNullOrEmpty(var)) { foreach (var prefix in var.Split(Path.PathSeparator)) { if (prefix.Length > 0) { yield return Path.Combine(prefix, path); } } } var = Environment.GetFolderPath(Environment.SpecialFolder.System); if (!String.IsNullOrEmpty(var)) { yield return Path.Combine(var, path); } var = pal.GetEnvironmentVariable("SystemRoot"); if (!String.IsNullOrEmpty(var)) { yield return Path.Combine(var, path); } } }