你的dir.GetFiles() 返回的尸身么?
test.test.testinfo吗?????????????

解决方案 »

  1.   

    what is dir? a DirectoryInfo instance? the error is not obvious, show more code
      

  2.   

    请问两位大侠另一个问题
    急问为什么一直出现"异常详细信息: System.Web.HttpException: 响应在此上下文中不可用" 
    namespace test.test
    {
    public class caculate2 : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.TextBox txtA;
    protected System.Web.UI.WebControls.TextBox txtB;
    protected System.Web.UI.WebControls.Label labAdd;
    protected System.Web.UI.WebControls.Label labSub;
    protected System.Web.UI.WebControls.Button Button1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    } private void Button1_Click(object sender, System.EventArgs e)
    {
    Caculate my = new Caculate();
    my.x = int.Parse(txtA.Text.ToString());
    my.y = int.Parse(txtB.Text.ToString());
    my.Add();
    my.Sub();
    } public void ListAdd(string a)
    {
    labAdd.Text = a;
    //为什么一直在这行提示:异常详细信息: System.Web.HttpException: 响应在此上下文中不可用。
    } public void ListDel(string b)
    {
    labSub.Text = b;
    }
    } public class Caculate
    {
    public int x,y,z;
    caculate2 my2 = new caculate2();
    public void Add()
    {
    z = x + y;
    my2.ListAdd(z.ToString());
    }
    public void Sub()
    {
    z = x - y;
    my2.ListDel(z.ToString());
    }
    }
    }
      

  3.   

    也就是这个贴子,当时贴了好几天都没有解决,只好解贴了请两位帮我看看谢谢了http://community.csdn.net/Expert/topic/3135/3135013.xml?temp=.9680597
      

  4.   

    请问为什么在.cs文件中写 foreach(FileInfo file in dir.GetFiles()) 提示出错 
    我已经找出了原因请大家帮我看看这个
    急问为什么一直出现"异常详细信息: System.Web.HttpException: 响应在此上下文中不可用"也就是这个 
    http://community.csdn.net/Expert/topic/3135/3135013.xml?temp=.9680597
    非常感谢
      

  5.   

    because if you create a page object programmatically,caculate2 my2 = new caculate2(); the controls in your page are not hooked up to the variables, so labAdd and labSub are nulltry
    public class Caculate
    {
    caculate2 c2;
    public Caculate(caculate2 c)
    {
    c2 = c;
    } public int x,y,z;

    public void Add()
    {
    z = x + y;
    c2.ListAdd(z.ToString());
    }
    public void Sub()
    {
    z = x - y;
    c2.ListDel(z.ToString());
    }
    }
    thenCaculate my = new Caculate(this);
      

  6.   

    非常感谢 saucer(思归/MVP)这个问题我郁闷了一个月,今天终于被你解决了.也感谢各位CSDN网友