In a C # application, it can take from 1 to 2100 hours of data gathering. The data is saved in a CSV Excel spreadsheet every minute. With the code below we can hide and show the file.
#region
string diret=saveFileDialog1.FileName;
Encoding sjisX=Encoding.GetEncoding("Shift_JIS");
StreamWriter arquivo=new StreamWriter(diret,true,sjisX);
FileInfo fileProtec=new FileInfo(saveFileDialog1.FileName);
fileProtec.Attributes=FileAttributes.Archive;
arquivo.Write(tb_csv.Text);
arquivo.Close();
fileProtec.Attributes=FileAttributes.Hidden;
#endregion
Even with this protection, you can open the file in Excel. If the file is open the data will not be saved. What is the smart and smart way to prevent this file from being opened until data collection is complete?