I want to write to a file using a streamwriter.
using (StreamWriter sw = new StreamWriter(@"D:\Documents\MathsPrograms\Prime2.csv", false))
{
}
Open in new window
How can I get the program to give an error message if the file is locked eg another program is writing to it, or a user has the file open in Excel?