using System.IO; using System.Reflection; using System.Xml;
FileStream refs = new FileStream("url.xls", FileMode.Open, FileAccess.Read); byte[] infbytes = new byte[(int)refs.Length]; refs.Read(infbytes, 0, infbytes.Length); refs.Close(); //將xls文件轉換為byte 字節 url.xls讀取路徑
FileStream Wrfs = new FileStream("url.dbf", FileMode.Create, FileAccess.Write); Wrfs.Write(infbytes, 0, infbytes.Length); Wrfs.Close(); //將byte字節轉換dbf文件 url.dbf保存路徑
Common.DBFFile BC = new Common.DBFFile(); BC.Open("url.dbf"); DataSet ds = BC.GetDataSet(); BC.Close(); //打開dbf文件轉換DataSet Common 打開路徑
string xml_path = HttpContext.Current.Server.MapPath(file_name); ds.WriteXml(xml_path); ds.Dispose(); //DataSet 轉換XML file_name文件名
string path = HttpContext.Current.Server.MapPath(xml_name); XmlDocument xml = new XmlDocument(); xml.Load(path); string strXmlTxt = xml.InnerText; string strXml = xml.InnerXml; //用這種 DataSet ds = new DataSet(); if (!string.IsNullOrEmpty(strXml)) { StringReader StrStream = null; XmlTextReader Xmlrdr = null; try { //讀取字符串中的信息 StrStream = new StringReader(strXml); //獲取StrStream中的數據 Xmlrdr = new XmlTextReader(StrStream); //ds獲取Xmlrdr中的數據 ds.ReadXml(Xmlrdr); } catch (Exception) { } finally { //釋放資源 if (Xmlrdr != null) { Xmlrdr.Close(); StrStream.Close(); StrStream.Dispose(); } } }
Common