I am somewhat new to C# but not new to coding itself. I am currently trying to write a console app to run some processes, gather information from those processes, and then write the values to a .txt file.
I have everything running smoothly in Visual Studio 2017 RC but when I publish and run the program everything runs except the part where the values/data is published to a document on my desktop. Can someone point me in the right direction or inform me why it is working in Visual but not in the program?
public static bool WriteData(string DataNeeded)
{
string Root = @"\text.txt";
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + Root;
if (!File.Exists(path))
{
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("Header of TXT file");
sw.WriteLine("Document created: " + DateTime.Now);
}
}
using (StreamWriter sw = File.AppendText(path))
{
sw.WriteLine("Data being written to text file: " + DataNeeded+ " " + DateTime.Now);
}
return true;
}