Reputation: 95
Thank you all I have found a viable solution with the aid of @NigelWhatling.
I want to store the file within the project folder and not inside the debug folder where it is currently saving to.
So I have used direct locations to save my files howerver I want to save them within the project folder. I have tried to use the code :
AppDomain.CurrentDomain.BaseDirectory;
code example :
string directory = AppDomain.CurrentDomain.BaseDirectory;
string NameOfFile = "test.txt";
string path= Path.Combine(directory , NameOfFile );
using (StreamWriter sw= new StreamWriter(path, true))
{
sw.WriteLine("Hello world");
}
This code gives me the location of where the programme was run
C:\Users\sam\source\repos\Project\server\bin\Debug
But I want to save within the Project folder where all the projects file are located. How can I do this. Any help will be appreciated.
Upvotes: 1
Views: 2508