C#C
C#3y ago
Solar

❔ 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;
            

        }
Was this page helpful?
❔ Code Not Writing To Text File - C#