我用的编程软件是microsoft visual studio 2008,我的想法是这样的:新建一个Button控件,然后在ButtonClick事件中写代码,等运行时候一按Button后就开始读取XML文件,并获取当前系统时间,等XML文档载入完成后再读入一次系统时间,两个时间相减,就是读取所需要的时间了。但是有个问题就是:怎么获取第二次的系统时间呢,没头绪啊
哪位好心人帮帮我啊。
我读取第一次时间的代码时这样的:
protected void Button2_Click(object sender, EventArgs e)
{
DateTime s = DateTime.Now;
Label2.Text = "现在是" + s.ToLongTimeString();
}
谢谢了!
哪位好心人帮帮我啊。
我读取第一次时间的代码时这样的:
protected void Button2_Click(object sender, EventArgs e)
{
DateTime s = DateTime.Now;
Label2.Text = "现在是" + s.ToLongTimeString();
}
谢谢了!
Thread.Sleep(2222);
string endTime = DateTime.Now.ToString();
//读xml
DateTime ss = DateTime.Now;
protected void Page_Load(object sender, EventArgs e)
{
DateTime s = DateTime.Now;
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("XMLFile1.xml"));
GridView1.DataSource=ds.Tables[0].DefaultView;
GridView1.DataBind();
DateTime ss = DateTime.Now;
Label3.Text = ss.ToLongTimeString() - s.ToLongTimeString(); }
是按照3楼说的写的,貌似运行不出来,我觉得最后一行貌似有问题啊,哪位高手帮我看下,谢谢了。我的结果是输出在Label3里的。
ds.ReadXml(Server.MapPath("XMLFile1.xml"));
GridView1.DataSource=ds.Tables[0].DefaultView;
GridView1.DataBind();
DateTime ss = DateTime.Now;
这段代码绝对没问题,我单独运行过的,行的。
我估计问题就出在DateTime s = DateTime.Now;
和最后两行里