Besides what Mark said in his solution regarding the access rights issues there is a serious design flaw in your approach. Since you are using
System.IO.File.WriteAllText[
^] the file will be overwritten upon each write request which does not sound very useful. Should you use another approach like opening, writing and closing the file to preserve previous entries you'll run into concurrency issues as to separate requests might cause a writing to said file and you'll have to make sure to handle these well.
To save yourself the trouble why not use a logging framework like log4Net. It's a spinoff from
log4J[
^] and can be found here:
What is Apache log4net™[
^].
Regards,
Manfred