❔ Code Not Writing To Text File
So I'm very new to c# (Just Started A couple hours ago) I code other languages though so I'm not a complete beginner but basically all I need help with is diagnosing and fixing why my method wont write to a text file
public static void Writer(string paintingType, int saleVal)
{
if (File.Exists("paintingHistory.txt"))
{
}
else
{
File.Create("paintingHistory.txt");
}
int cost = paint_Types[paintingType];
string data = paintingType+":" +":"+ Convert.ToString(cost)+":" + Convert.ToString(saleVal)+":\n";
using (StreamWriter sw = File.AppendText("paintingHistory.txt"))
{
sw.WriteLine(data);
}
return;
}File.WriteAllText method.


File.WriteAllTextdef writer(type,price,sold):
print(type,price,sold)
text = "{}:{}:{}:\n".format(type,price,sold)
print(text)
with open("paintingHistory.txt","a") as f:
f.write(text)
f.close()string existingData = File.ReadAllText("C:\\paintingHistory.txt");
int cost = paint_Types[paintingType];
string data = paintingType+":" +":"+ Convert.ToString(cost)+":" + Convert.ToString(saleVal)+":\n";
string newData = existingData + data;
File.WriteAllText("C:\\paintingHistory.txt", newData);