How to block a user's opening, reading, and editing of a file during the time the application is running?
An application has a relatively long data collection period. This application reads data in real time. The data read is written to the file every minute. At the end of data collection, I must release the file to the user. I use the code below to save the data every minute. The hidden and read only file attributes do not help me!
string diret=saveFileDialog1.FileName;
Encoding sjisX=Encoding.GetEncoding("Shift_JIS");
StreamWriter arquivo=new StreamWriter(diret,true,sjisX);
arquivo.Write(tb_csv.Text); //salva os dados.
arquivo.Close(); // fecha o arquivo.
//fileProtec.Attributes=FileAttributes.Hidden; permite sua abertura, logo, não serve!