コード例 #1
0
        /// <summary>
        /// Get directory name from path.
        /// </summary>
        /// <remarks>
        /// Unlike <see cref="System.IO.Path.GetDirectoryName"/> it
        ///     doesn't check for invalid path characters,
        ///     doesn't strip any trailing directory separators (TODO: tomat),
        ///     doesn't recognize UNC structure \\computer-name\share\directory-name\file-name (TODO: tomat).
        /// </remarks>
        /// <returns>Prefix of path that represents a directory. </returns>
        internal static string GetDirectoryName(string path)
        {
            int fileNameStart = FileNameUtilities.IndexOfFileName(path);

            if (fileNameStart < 0)
            {
                return(null);
            }

            return(path.Substring(0, fileNameStart));
        }
コード例 #2
0
        /// <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>
        internal 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);
        }
コード例 #3
0
 internal static string GetFileName(string path)
 {
     return(FileNameUtilities.GetFileName(path));
 }
コード例 #4
0
 internal static string RemoveExtension(string path)
 {
     return(FileNameUtilities.ChangeExtension(path, extension: null));
 }
コード例 #5
0
 internal static string ChangeExtension(string path, string extension)
 {
     return(FileNameUtilities.ChangeExtension(path, extension));
 }
コード例 #6
0
 internal static string GetExtension(string path)
 {
     return(FileNameUtilities.GetExtension(path));
 }