Export (0) Print
Expand All

Module.Name Property

Gets a String representing the name of the module with the path removed.

[Visual Basic]
Public ReadOnly Property Name As String
[C#]
public string Name {get;}
[C++]
public: __property String* get_Name();
[JScript]
public function get Name() : String;

Property Value

The module name with no path.

Remarks

Name is a platform-dependent string.

To get the name and the path, use FullyQualifiedName.

Example

[Visual Basic, C#, C++] This example shows the effect of the ScopeName, FullyQualifiedName, and Name properties.

[Visual Basic] 
Imports System.Reflection
Imports System

Public Class Simple
    
    Public Shared Sub Main()
        Dim myMod As System.Reflection.Module = _
           [Assembly].GetExecutingAssembly().GetModules()(0)
        Console.WriteLine("Module Name is " + myMod.Name)
        Console.WriteLine("Module FullyQualifiedName is " _
           + myMod.FullyQualifiedName)
        Console.WriteLine("Module ScopeName is " + myMod.ScopeName)
    End Sub
    
End Class

' This code produces the following output:
'
' Module Name is modname.exe
' Module FullyQualifiedName is C:\Bin\modname.exe
' Module ScopeName is modname.exe 

[C#] 
using System.Reflection;
using System;
 
 public class Simple
 {
    public static void Main ()
    {
         Module mod = Assembly.GetExecutingAssembly().GetModules () [0];
         Console.WriteLine ("Module Name is " + mod.Name);
         Console.WriteLine ("Module FullyQualifiedName is " + mod.FullyQualifiedName);
         Console.WriteLine ("Module ScopeName is " + mod.ScopeName);
    }
 }
 /*
 This code produces the following output:

 Module Name is modname.exe
 Module FullyQualifiedName is C:\Bin\modname.exe
 Module ScopeName is modname.exe
 */

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Reflection;

int main ()
{
    Module* mod = Assembly::GetExecutingAssembly()->GetModules () [0];
    Console::WriteLine (S"Module Name is {0}", mod->Name);
    Console::WriteLine (S"Module FullyQualifiedName is {0}", mod->FullyQualifiedName);
    Console::WriteLine (S"Module ScopeName is {0}", mod->ScopeName);
}
/*
This code produces the following output:

Module Name is modname.exe
Module FullyQualifiedName is C:\Bin\modname.exe
Module ScopeName is modname.exe
*/

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Module Class | Module Members | System.Reflection Namespace

Show:
© 2014 Microsoft