need your eye on this.
void testSave()
{
fileName = curMonth.Text + curYear.Text + ".csv";
if (!File.Exists(path+fileName))
{
File.Create(path + fileName);
}
else if (File.Exists(path + fileName))
{
try
{
lines = curDate.Text + "," + myDesc.Text + "," + myAmount.Text;
File.AppendAllText(path + fileName, lines + Environment.NewLine);
TextWriter tw = new StreamWriter(path + fileName, true);
tw.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
The error come out as below:
The process cannot access the file 'C:\Users...\File.csv' because it is being used by another process.
Any suggestion or solution i could refer? thanks