So basically what i have done is created a program, whever i click button "start" it creates a folder in the main folder. In that folder it creates 2 text files.
So whenever i click a button in this case button9 i want it to save it in that folder and overwrite text file #1.
So what it does now is, i found a way to make it save the text file in the main folder but not in the folder that is made after pressing start.
I have tried to fix it for like 2 days but can't find a solution.
Code for the button that saves it:
var saveFile = new SaveFileDialog();
string path = System.IO.Directory.GetCurrentDirectory();
saveFile.InitialDirectory = path;
saveFile.FileName = "Good";
saveFile.Filter = "Text (*.txt)|.txt";
using (var sw = new StreamWriter(saveFile.FileName + ".txt"))
foreach (var item in listBox1.Items)
sw.Write(item.ToString() + Environment.NewLine);
The folder that is created after clicking start:
string myDate = DateTime.Today.ToString(" [yyyy-MM-dd]");
DateTime now1 = new DateTime();
now1 = DateTime.Today;
string today = now1.ToString();
Directory.CreateDirectory("Results" + myDate);
File.AppendAllText(Path.Combine("Results" + myDate, "Good.txt"), listBox1.Text);
File.AppendAllText(Path.Combine("Results" + myDate, "Bad.txt"), listBox2.Text);
so the question is how do i make the txt file (from button9) go in that folder(from start button)?
What I have tried:
tried to find a way to make it find the folder, it is little sketchy for me because the name has date in it.