查询ACCESS
/// <summary> /// OleDb查询数据库返回内容 /// </summary> /// <param name="sql_str"></param> /// <returns></returns> protected DataTable dlBind(string sql_str) { oCon.Open(); OleDbCommand ps = new OleDbCommand(sql_str, oCon); DataTable dt = new DataTable(); dt.Load(ps.ExecuteReader()); oCon.Close(); return dt; }
打开文件并读取内容,保存字符到文件.
/// <summary> /// 打开文件,反回字符串 /// </summary> /// <param name="file_path">"SyntaxHighligher/com.html"</param> /// <returns></returns> private string openfiletext(string file_path) { StreamReader htmlreader = new StreamReader(file_path); return htmlreader.ReadToEnd(); } /// <summary> /// 保存字符串到文件 /// </summary> /// <param name="filetext"></param> /// <param name="file_path">"SyntaxHighligher/com.html"</param> private void writefiletext(string filetext,string file_path) { FileStream MyFileStream = new FileStream(file_path, FileMode.Create, FileAccess.Write); StreamWriter htmlWriter = new StreamWriter(MyFileStream, System.Text.Encoding.UTF8); htmlWriter.WriteLine(filetext); htmlWriter.Close(); MyFileStream.Close(); }
时间: 2024-10-19 05:19:13