I have a unit test project called "RegressionTests".
In here are various sub-folders one of which is called "FileUpload"
In this folder there is a cs file called "FileUploadRegressionTests.cs" and a source file called "test.txt". test.txt is set to be copied to the output folder.
In my unit test when I run it I try the following:
if (System.IO.File.Exists("test.txt")) {Console.Write("FOUND 1\r\n");}
if (System.IO.File.Exists("FileUpload\\test.txt")) {Console.Write("FOUND 2\r\n");}
if (System.IO.File.Exists("C:\\dev\\...FileUpload\\test.txt")) {Console.Write("FOUND 3\r\n");}
So here I am trying to access the file. If I use a relative path test.txt or 'FileUpload\test.txt' (because in the output folder it is copied into the project subfolder) it does not find the file. Only if I use the absolute path will it find the file... I can't leave it like this otherwise the next person to run the test will fail if they clone the project into a different folder.
I tried to get the current directory with:
System.IO.Directory.GetCurrentDirectory()
But this just returns C:\Windows\System (or something like this)
How can I reference my file with a relative path?