using System; namespace StackFrame { class ClassMain { public static void Test() { // Get the Callstack one Method up. System.Diagnostics.StackFrame CallStack = new System.Diagnostics.StackFrame(1, true); Console.WriteLine( CallStack.GetFileName() ); // This should out: "..../Main.cs" Console.WriteLine( CallStack.GetFileLineNumber() ); // This should out: 20 Console.WriteLine( CallStack.GetMethod().Name ); // This should out: Main } [STAThread] static void Main(string[] args) { Test(); Console.ReadLine(); } } }