2 Replies - 599 Views - Last Post: 13 January 2022 - 07:12 AM Rate Topic: -----

#1 ScottinTexas   User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 396
  • Joined: 13-March 12

Application.StartupPath Is Wrong

Posted 01 December 2021 - 08:55 AM

When I run the code the Application.StartupPath points to the folder where the .exe lives. But when I am running a unit test it points to "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform\Archive\202112 Log.txt" and, of course, crashes because the folder does not exist there. The Archive folder exists in the path ..\MyProgram\MyProgramTests\bin\Debug\. Why is it pointing there? How do I make the unit testing look in the right place for the folder?

Is This A Good Question/Topic? 0
  • +

Replies To: Application.StartupPath Is Wrong

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 16503
  • View blog
  • Posts: 65,458
  • Joined: 12-June 08

Re: Application.StartupPath Is Wrong

Posted 02 December 2021 - 08:29 AM

Hmm. I haven't run across that.

Which unit testing route are you using?
Was This Post Helpful? 0
  • +
  • -

#3 ScottinTexas   User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 396
  • Joined: 13-March 12

Re: Application.StartupPath Is Wrong

Posted 13 January 2022 - 07:12 AM

Hi Modi123-1. I am not sure what you are asking. I just added a Unit Test project to my solution in VS. Then I add a unit test class for each class in the app. Then I just write <TestMethod()>s in the unit test classes. When I select "Add" in the project I just choose "Unit Test" from the menu.

The question has been sitting here for a while, but that's because the problem is low priority and I have been putting out fires. But I would like to clear up this weirdness. Today, I wrote a Test Method, forgetting about this post. It worked just fine! So now the whole question is moot.

If you can think of something that might have contributed to the problem described, then I would like to hear it. Otherwise we can scrap this whole thing until the problem comes up again.

Thanks,
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1