c# - CSV file writing ASP.NET concurrency issue -


i have web form in .aspx form takes users details , writes details csv file in c# located on server. question how can control multiple writes csv file data doesn't messed up? must absolutely use csv file on server, database or other ways record not option me.

looking around have seen using mutex may useful. wondering other options have looking efficient , simplest solution? apologise in advance new asp.net , c#.

using mutex/lock easiest way; assuming site writer of csv file. since no code shown, i'll assume have csvwriter class:

public class csvwriter {     const string path = "myfile.csv";      static object synch = new object();      public void appendcsv(string newdata)     {         lock (synch)         {             file.appendalltext(path, newdata);         }     } } 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -