When launch from test framework, the Application.StartupPath looks like "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\EXTENSIONS\TESTPLATFORM" which may not have write permission.