src/Microsoft/Windows/ComponentObjectModel/_Library/Utils.cs
/// <summary>
/// Constructs a base path from a given path.
/// </summary>
/// <param name="path">The input path.</param>
/// <returns>The base path.</returns>
/// <remarks>
/// The base path can be constructed from pathes to a comhost.dll.
/// </remarks>
Constructs a base path from a given path.
Constructs a base path from a given path .
public static string GetBasePath( string path ) {
            string basePath        = Path.GetDirectoryName( Path.GetFullPath( path) );
            string filename        = Path.GetFileName( path );
            string[] filenameParts = filename.Split( '.' );
            if ( filenameParts.Length < 2 ) {
                throw new FormatException();
            }
            int filenamePartsCount = 0;
            if ( filenameParts[filenameParts.Length - 1].Equals( "dll", StringComparison.OrdinalIgnoreCase ) ) {
                filenamePartsCount = filenameParts.Length - 1;
                if ( filenameParts.Length >= 3 ) {
                    if ( filenameParts[filenameParts.Length - 2].Equals( "comhost", StringComparison.OrdinalIgnoreCase ) ) {
                        filenamePartsCount -= 1;
                    }
                }
            }
            if ( filenameParts[filenameParts.Length - 1].Equals( "json", StringComparison.OrdinalIgnoreCase ) ) {
                throw new NotImplementedException();
            }
            return Path.Combine( basePath, string.Join( ".", filenameParts, 0, filenamePartsCount ) );
        }
public static string GetBasePath ( string path ) { string basePath = Path . GetDirectoryName ( Path . GetFullPath ( path ) ) ; string filename = Path . GetFileName ( path ) ; string [ ] filenameParts = filename . Split ( ' ' ) ; if ( filenameParts . Length < 2 ) { throw new FormatException ( ) ; } int filenamePartsCount = 0 ; if ( filenameParts [ filenameParts . Length - 1 ] . Equals ( " " , StringComparison . OrdinalIgnoreCase ) ) { filenamePartsCount = filenameParts . Length - 1 ; if ( filenameParts . Length >= 3 ) { if ( filenameParts [ filenameParts . Length - 2 ] . Equals ( " " , StringComparison . OrdinalIgnoreCase ) ) { filenamePartsCount -= 1 ; } } } if ( filenameParts [ filenameParts . Length - 1 ] . Equals ( " " , StringComparison . OrdinalIgnoreCase ) ) { throw new NotImplementedException ( ) ; } return Path . Combine ( basePath , string . Join ( " " , filenameParts , 0 , filenamePartsCount ) ) ; }
Constructs a base path from a given path.
Constructs a base path from a given path .
// Dynamic Link Libraries (*.dll) // <library>.dll // <library>.comhost.dll // .json config files
The base path.
The base path .
path
string
The input path.
The input path .
remarks
The base path can be constructed from pathes to a comhost.dll.
The base path can be constructed from pathes to a comhost . dll .