TextWriterTraceListener Not Creating File

Nathan Sokalski 4,121 Reputation points

I am attempting to use TextWriterTraceListener for the first time. I currently have the following code:

TextWriterTraceListener testresultslistener = new TextWriterTraceListener("MyOutput.txt");  
testresultslistener.WriteLine("My Output");  

However, it does not seem to be creating a file. What am I doing wrong?

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,387 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jack J Jun 24,311 Reputation points Microsoft Vendor

    @Nathan Sokalski , based on my test, Viorel's code is correct. The output folder means that bin/debug folder, like the following:


    You also use the following code to get your current output path.

      string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);  

    Best Regards,

    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.