bomforpconync
New Member
Reading the documentation I thought this code would write logs to a file in a threadsafe way. \[code\]using (TextWriter syncTextWriter = TextWriter.Synchronized(new StreamWriter(Server.MapPath(String.Format("~/App_Data/PaypalIPN/IPNlog_{0:yyyyMM}.txt", DateTime.Now)), true))){ syncTextWriter.WriteLine(line); syncTextWriter.Close();}\[/code\]I do not have a high traffic site, but every now and again two people make a paypal payment at the same time, and this is the IPN payment log. Despite introducing \[code\]TextWriter.Synchronized\[/code\] I am still getting the odd exception:\[code\]System.IO.IOException: The process cannot access the file ... ...because it is being used by another process.\[/code\]Where have I gone wrong?