0

I'm trying to write my errors into the text file in my MapPath. But i have a problem it is :

path = Server.MapPath("~/emails.txt");

Actually Server is in System.Web.UI.Page namespace and I want to Use it in my cs file which has no aspx file... I mean it is CodeFile in AppCode; How can I write to file from cs CodeFile?

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
amin
  • 1,194
  • 1
  • 12
  • 20
  • I've changed title to match you question - feel free to edit/revert. Note that you'll hit `IOException`/"access denied" exceptions - search for similar questions to find how to setup permissions for this to succeed, OR use existing logging libraries - again many topics on that. – Alexei Levenkov Dec 06 '13 at 17:39

1 Answers1

9

Use HttpContext.Current.Server.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964