Hi All,
This is my first post, I've been finding lots of solutions from this forum. Thanks to all who helped (and ones who asked questions).
I have a strange problem. I'm having a console app and one of the classes in this application needs to read a file from file system. The path is one directory below app path. e.g. if application is in C:\MyApp then the file would be in C:\MyApp\DataFi les directory. I used Reflection to get the path for my executable and just appended the subdirectory name to it for getting file.
Code: string sPath = System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location;
It works in all cases, but with NUnit, as NUnit makes a Shadow copy of the loaded assembly, my subdirectory cant be located by my function and the test fails.
Everything works with console app running from cmd prompt, but I cant have NUnit test for it.
Can anyone suggest any way to get the path while running NUnit?
I dont want to use hardcoded path in App.config as it'll be changed with each installation.
Pls dont mind my way of putting the query, as this is my first post.
Thanks for responses in advance.
Cheers,
Nik
This is my first post, I've been finding lots of solutions from this forum. Thanks to all who helped (and ones who asked questions).
I have a strange problem. I'm having a console app and one of the classes in this application needs to read a file from file system. The path is one directory below app path. e.g. if application is in C:\MyApp then the file would be in C:\MyApp\DataFi les directory. I used Reflection to get the path for my executable and just appended the subdirectory name to it for getting file.
Code: string sPath = System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location;
It works in all cases, but with NUnit, as NUnit makes a Shadow copy of the loaded assembly, my subdirectory cant be located by my function and the test fails.
Everything works with console app running from cmd prompt, but I cant have NUnit test for it.
Can anyone suggest any way to get the path while running NUnit?
I dont want to use hardcoded path in App.config as it'll be changed with each installation.
Pls dont mind my way of putting the query, as this is my first post.
Thanks for responses in advance.
Cheers,
Nik
Comment