日期:2014-05-18 浏览次数:21276 次
private void SaveDocument()
        {
            SqlConnection cn = new SqlConnection(@"连接字符串");
            FileInfo fi = new FileInfo(@"C:\200801110040004.xml");
            FileStream fs = fi.OpenRead();
            byte[] bytes = new byte[fs.Length];
            fs.Read(bytes, 0, Convert.ToInt32(fs.Length));
            fs.close();
            SqlCommand cm = new SqlCommand();
            cm.Connection = cn;
            cm.CommandType = CommandType.Text;
            cm.CommandText = "insert into  FileTable ( FileStr) values(@file)";
            SqlParameter spFile = new SqlParameter("@file", SqlDbType.Image);
            spFile.Value = bytes;
            cm.Parameters.Add(spFile);
            cn.Open();
            cm.ExecuteNonQuery();
            cn.Close();
        }
------解决方案--------------------
处理应该用xmldocument+xpath把,最后保存的时候直接更改文件后缀即可
xml是可以用文本格式才存放的
  xmldocument doc=new xmldocument();
  doc.load(@"d:\fsj.xml");
   
  xmlnode root=doc.documentElement;
  root.selectnodes/selectSinglenode();
  ... ...
  处理
  doc.save(@"c:\fsj.txt")