我在Global.asax的Application_Start 里写方法,那么这个时候Server对象是不还没有创建甚至是HttpContext对象都还没有创建????
可是我要在这个时候读取项目里的一个文件,这时该怎么办呢????

解决方案 »

  1.   

    可以在这里写,但要注意这个是全局的,如果针对不同的用户请到SESSION_STARTA中写!
      

  2.   

    读项目里的文件什么时候都可以。
    application_start里面可以做你想做的事
    都可以调用数据库了,你说呢?
      

  3.   

    可是我使用Server 的时候报未找到对象的错
      

  4.   

    可以读取
    http://msdn.microsoft.com/zh-cn/library/ms178472(VS.80).aspx
      

  5.   

    protected void Application_Start(Object sender, EventArgs e)
    {
    string strfile=Server.MapPath("/counter.txt");
    }
      

  6.   

    我的方法是写在App_Code 里面的,会不会有影响??
      

  7.   

    System.NullReferenceException: 未将对象引用设置到对象的实例。
       在 SendEmailInTime.UpdateState(String userEmail, String state) 位置 e:\邮件群发\SendEmailWeb\App_Code\SendEmailInTime.cs:行号 186
       在 SendEmailInTime.SendEmail(String InceptMan, String userName, String title, String emailContent, String file) 位置 e:\邮件群发\SendEmailWeb\App_Code\SendEmailInTime.cs:行号 72
       在 ScheduledTask.UpdateTimerCallback(Object sender) 位置 e:\邮件群发\SendEmailWeb\App_Code\ScheduledTask.cs:行号 74
    我晕
      

  8.   

    我在Application_Start 中调用用App_Code\ScheduledTask.cs 里的方法,
    然后 在ScheduledTask 里调用  SendEmailInTime.cs 里的方法,就出问题了