OleDbConnection Mycon = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=MyDb.mdb"); FileStream fs = new FileStream(filename,FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); byte[] mywave = br.ReadBytes((int)fs.Length); br.Close(); fs.Close(); Mycon.Open(); string sql = "insert into MyDataBase(wav,MyWord) VALUES (@wav,'"+textBox1.Text.Trim()+"')"; OleDbCommand cmd = new OleDbCommand(sql, Mycon); cmd.Parameters.Add("@wav", OleDbType.Binary, photo.Length).Value = mywave ; cmd.ExecuteNonQuery(); Mycon.Close(); #region 对文本文件的读写 FileStream fs = new FileStream(@"r:''txt.txt", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite); FileStream f = File.Open(@"r:''f.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); string s = "秋伟光lov.09823p''''=!@#%.;"; byte[]inb = System.Text.Encoding.UTF8.GetBytes(s); //和下面一样这个容易理解 //byte[] inb = new UTF8Encoding(true).GetBytes(s);//和上面的一样效果 fs.Write(inb, 0, inb.Length); fs.Flush(); //清空缓冲 fs.Close(); FileStream ff = File.OpenRead(@"r:''txt.txt"); byte[]a = new byte[ff.Length]; ff.Read(a, 0, (int)a.Length); f.Write(a, 0, (int)ff.Length); ff.Close(); f.Close(); #endregion #region 对二进制文件的读写 //System.IO.BinaryReader: 读二进制文件 //System.IO.BinaryWriter: 写二进制文件 //FileStream fs1 = new FileStream(@"r:''gif.gif",FileMode.OpenOrCreate,FileAccess.ReadWrite); //FileStream fs2 = new FileStream(@"r:''p1.bmp",FileMode.OpenOrCreate,FileAccess.ReadWrite); //FileStream fw = new FileStream(@"r:''new.txt",FileMode.OpenOrCreate,FileAccess.ReadWrite); //BinaryReader br = new BinaryReader(fs1); //BinaryWriter bw = new BinaryWriter(fw); //bw.Write(br.ReadInt32()); #endregion