Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get xUnit Solution Directory Path

Tags:

c#

.net

xunit

Does anyone have an idea of how I would be able to get and store(string) the path to my solution directory in an xUnit Project?

like image 229
Xeyth Avatar asked Feb 23 '26 08:02

Xeyth


2 Answers

Environment.CurrentDirectory works fine for what i need

like image 72
Xeyth Avatar answered Feb 25 '26 22:02

Xeyth


This works all the time

using System.IO;          // needed for Path
using System.Reflection;  // needed for Assembly

var path = new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath
var directoryPath = Path.GetDirectoryName(path)
like image 26
sree Avatar answered Feb 25 '26 22:02

sree



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!