/// <summary> /// Determines whether an assembly reference is considered an assembly file path or an assembly name. /// used, for example, on values of /r and #r. /// </summary> public static bool IsFilePath(string assemblyDisplayNameOrPath) { Debug.Assert(assemblyDisplayNameOrPath != null); string extension = FileNameUtilities.GetExtension(assemblyDisplayNameOrPath); return(string.Equals(extension, ".dll", StringComparison.OrdinalIgnoreCase) || string.Equals(extension, ".exe", StringComparison.OrdinalIgnoreCase) || assemblyDisplayNameOrPath.IndexOf(DirectorySeparatorChar) != -1 || assemblyDisplayNameOrPath.IndexOf(AltDirectorySeparatorChar) != -1); }
public static string GetFileName(string path, bool includeExtension = true) { return(FileNameUtilities.GetFileName(path, includeExtension)); }
public static string RemoveExtension(string path) { return(FileNameUtilities.ChangeExtension(path, extension: null)); }
public static string ChangeExtension(string path, string extension) { return(FileNameUtilities.ChangeExtension(path, extension)); }
public static string GetExtension(string path) { return(FileNameUtilities.GetExtension(path)); }
/// <summary> /// Checks that the specified name is a valid metadata String and a file name. /// The specification isn't entirely consistent and complete but it mentions: /// /// 22.19.2: "Name shall index a non-empty string in the String heap. It shall be in the format {filename}.{extension} (e.g., 'goo.dll', but not 'c:\utils\goo.dll')." /// 22.30.2: "The format of Name is {file name}.{file extension} with no path or drive letter; on POSIX-compliant systems Name contains no colon, no forward-slash, no backslash." /// As Microsoft specific constraint. /// /// A reasonable restriction seems to be a valid UTF8 non-empty string that doesn't contain '\0', '\', '/', ':' characters. /// </summary> public static bool IsValidMetadataFileName(string name) { return(FileNameUtilities.IsFileName(name) && IsValidMetadataIdentifier(name)); }