Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8453147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:41:36+00:00 2026-06-10T11:41:36+00:00

Is there a way to grab the function name and file name when I’m

  • 0

Is there a way to grab the function name and file name when I’m inside a function? I’m trying to add log files all over the place like so, and want to be able to just copy and paster my logfile line of code in certain functions:

public class NewCorrGenerator
{
    public void Start()
    {
        bool rc = true;

        myLogFile.InfoToFileWithTime("NewCorrGenerator - Start", appContext);

        etc.....
    }
}

As you can see is there a way to grab the class name and function name in a string and output it to myLogFile function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:41:38+00:00Added an answer on June 10, 2026 at 11:41 am

    You can use GetCurrentMethod. This will return an object of type MethodBase. The Name property to get the name of the method. DeclaringType will give you the class. This isn’t the same as the file name, but it should be close if you use one type per file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With a windows MSI file, is there a way to grab all the possible
Is there a good way to get the process name that created a file
Is there a way to grab the URL's hash value (e.g. the 35 in
Is there way to get file from windows xp command prompt? I tried to
Is there way to copy a file into Plone with WebDAV and have Plone
is there way how to get name ov event from Lambda expression like with
Is there way that I can read the file from remote server using fopen
Greetings all, I'm looking for a more efficient way to grab multiple users without
Is there a way to pass an unlimited amount of arguments to a function,
HTML <a href=report.php?id=5&file=name.jpg id=5 class=report>Report Content<span class=hidden>name.jpg</span></a> jQuery $('.report').click(function(event) { var id = this.id;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.