Bagikan melalui


StackFrame.GetFileName Metode

Definisi

Mendapatkan nama file yang berisi kode yang sedang dijalankan. Informasi ini biasanya diekstrak dari simbol debugging untuk executable.

public:
 System::String ^ GetFileName();
public:
 virtual System::String ^ GetFileName();
public string GetFileName ();
public virtual string? GetFileName ();
public virtual string GetFileName ();
member this.GetFileName : unit -> string
abstract member GetFileName : unit -> string
override this.GetFileName : unit -> string
Public Function GetFileName () As String
Public Overridable Function GetFileName () As String

Mengembalikan

Nama file, atau null jika nama file tidak dapat ditentukan.

Contoh

Contoh berikut menunjukkan penggunaan GetFileName metode . Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk StackFrame kelas .

// Display the stack frame properties.
StackFrame^ sf = st->GetFrame( i );
Console::WriteLine( " File: {0}", sf->GetFileName() );
Console::WriteLine( " Line Number: {0}", sf->GetFileLineNumber().ToString() );

// Note that the column number defaults to zero
// when not initialized.
Console::WriteLine( " Column Number: {0}", sf->GetFileColumnNumber().ToString() );
Console::WriteLine( " Intermediate Language Offset: {0}", sf->GetILOffset().ToString() );
Console::WriteLine( " Native Offset: {0}", sf->GetNativeOffset().ToString() );
// Display the stack frame properties.
StackFrame sf = st.GetFrame(i);
Console.WriteLine(" File: {0}", sf.GetFileName());
Console.WriteLine(" Line Number: {0}",
   sf.GetFileLineNumber());
// Note that the column number defaults to zero
// when not initialized.
Console.WriteLine(" Column Number: {0}",
   sf.GetFileColumnNumber());
if (sf.GetILOffset() != StackFrame.OFFSET_UNKNOWN)
{
   Console.WriteLine(" Intermediate Language Offset: {0}",
      sf.GetILOffset());
}
if (sf.GetNativeOffset() != StackFrame.OFFSET_UNKNOWN)
{
   Console.WriteLine(" Native Offset: {0}",
      sf.GetNativeOffset());
}
' Display the stack frame properties.
Dim sf As StackFrame = st.GetFrame(i)
Console.WriteLine(" File: {0}", sf.GetFileName())
Console.WriteLine(" Line Number: {0}", _
   sf.GetFileLineNumber())
' The column number defaults to zero when not initialized.
Console.WriteLine(" Column Number: {0}", _
   sf.GetFileColumnNumber())
If sf.GetILOffset <> StackFrame.OFFSET_UNKNOWN
   Console.WriteLine(" Intermediate Language Offset: {0}", _
       sf.GetILOffset())
End If
If sf.GetNativeOffset <> StackFrame.OFFSET_UNKNOWN
  Console.WriteLine(" Native Offset: {0}", _
      sf.GetNativeOffset())
End If

Berlaku untuk