net 当中动态给记事本当中插入值


                string url = Server.MapPath("dingdan")+"\\";//ConfigurationManager.AppSettings["filepath"].ToString();
                String fileName = "dingdan"; //DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");//Guid.NewGuid().ToString();
                String path = url + fileName + ".txt";            
                  
                FileStream fs = new FileStream(path, FileMode.OpenOrCreate);
                string body = DateTime.Now.ToString() + (char)13 + (char)10 + "z客户" + Request["name"].ToString() + "的订单内容如下" + (char)13 + (char)10 + ""
                   + "性别:" + Request["sex"].ToString() + (char)13 + (char)10 + ""
                      + "手机:" + Request["phone"].ToString() + (char)13 + (char)10 + ""
                       + "地址:" + Request["addr"].ToString() + (char)13 + (char)10 + ""
                      + "产品:" + Request["chanpin"].ToString() + (char)13 + (char)10 + "";
                string s = "\n\r" + body + "\n\r";
                Byte[] ts = System.Text.Encoding.UTF8.GetBytes(s);                 
                 
                 //设定书写的开始位置为文件的末尾  
                 fs.Position = fs.Length;   
                 //将待写入内容追加到文件末尾  
                 fs.Write(ts, 0, ts.Length);      
                    fs.Dispose();
                    fs.Close();
                    GC.Collect();

posted @ 2013-05-22 17:48  AStronghcm  阅读(191)  评论(0编辑  收藏  举报